Commit 91c7b16c authored by jianghaiming's avatar jianghaiming

Merge branch 'develop' into test

parents 8f2a6787 12d5d538
......@@ -44,5 +44,6 @@ class GoodsException extends BaseException
30 => '当前商品已过期',
31 => '当前商品锁定库存不足',
32 => '当前商品已下单数量不足',
33 => '售价不能为0',
];
}
\ No newline at end of file
......@@ -11,16 +11,13 @@ use Api\PhpUtils\Mysql\MysqlBase;
*/
class Tcc extends MysqlBase
{
const STATUS_T_SUCCESS = 1;
const STATUS_C1_SUCCESS = 2;
const STATUS_C2_SUCCESS = 3;
const TABLE_NAME = 'inventory_tcc_record';
const CONFIG_INDEX = 'goods';
const STATUS_TRY = 1;// try
const STATUS_CONFIRM = 2;// confirm
const STATUS_CANCEL = 3;// cancel
const OPERATOR_RESULT_FAIL = 0;// 失败
const OPERATOR_RESULT_SUCCESS = 1;// 成功
public static function getRecord($where, $columns = [])
{
if (empty($columns)) {
......
......@@ -3,9 +3,7 @@
use App\Base\Base;
use App\Exception\custom\GoodsException;
use \Validate\GoodsTccValidate;
use \Validate\GoodsTccIsFinishValidate;
use \Validate\GoodsTccCancelValidate;
use \App\Services\tcc\TccService;
use \App\Services\tcc\Tcc2Service;
class TccController extends Base
......@@ -19,7 +17,7 @@ class TccController extends Base
{
(new GoodsTccValidate())->validate();
$res = TccService::placeAnOrderTry($this->params["keys"], $this->params["tid"]);
$res = Tcc2Service::placeAnOrderTry($this->params["keys"], $this->params["tid"]);
if ($res) {
$this->success();
} else {
......@@ -36,7 +34,7 @@ class TccController extends Base
{
(new GoodsTccValidate())->validate();
$res = TccService::placeAnOrderConfirm($this->params["keys"], $this->params["tid"]);
$res = Tcc2Service::placeAnOrderConfirm($this->params["keys"], $this->params["tid"]);
if ($res) {
$this->success();
} else {
......@@ -45,7 +43,7 @@ class TccController extends Base
}
/**
* 下单商品 tcc cancel
* 下单商品 cancel
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
......@@ -53,24 +51,7 @@ class TccController extends Base
{
(new GoodsTccValidate())->validate();
$res = TccService::placeAnOrderCancel($this->params["keys"], $this->params["tid"]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
* 取消订单单 商品tcc try
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
public function cancel_order_tryAction()
{
(new GoodsTccValidate())->validate();
$res = TccService::cancelOrderTry($this->params["keys"], $this->params["tid"]);
$res = Tcc2Service::placeAnOrderCancel($this->params["keys"], $this->params["tid"]);
if ($res) {
$this->success();
} else {
......@@ -80,47 +61,12 @@ class TccController extends Base
/**
* 取消订单单 商品tcc confirm
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
public function cancel_order_confirmAction()
{
(new GoodsTccCancelValidate())->validate();
$res = TccService::cancelOrderConfirm($this->params["keys"], $this->params["tid"], $this->params["type"]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
* 取消订单单 商品tcc cancel
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
public function cancel_order_cancelAction()
{
(new GoodsTccValidate())->validate();
$res = TccService::cancelOrderCancel($this->params["keys"], $this->params["tid"]);
$res = Tcc2Service::cancelConfirm($this->params["keys"]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
* 判断当前tcc是否执行完成
* @throws \App\Exception\custom\ParamException
*/
public function tcc_is_finishAction()
{
(new GoodsTccIsFinishValidate())->validate();
$res = TccService::tccIsFinish($this->params["goods_sku_id_str"], $this->params["tid"]);
$this->success(["result"=>$res]);
}
}
\ No newline at end of file
......@@ -153,7 +153,7 @@ class ElasticGoodService
$result["list"][$key]["life_account_id"] = $source["_source"]["life_account_id"];
$result["list"][$key]["life_account_name"] = $source["_source"]["life_account_name"];
$result["list"][$key]["life_account_icon"] = $source["_source"]["life_account_icon"];
$result["list"][$key]["distance"] = empty($source["sort"][0]) ? "" : round($source["sort"][0], 2) . "km";
$result["list"][$key]["distance"] = empty(end($source["sort"])) ? "" : round(end($source["sort"]), 2) . "km";
$result["list"][$key]["update_time"] = $source["_source"]["update_time"];
}
}
......
......@@ -176,6 +176,9 @@ class GoodsService
if ($skuData["expiration_time"] < date("Y-m-d H:i:s")) {
throw new GoodsException(['cus' => 16]);
}
if ($skuData["price"] <= 0) {
throw new GoodsException(['cus' => 33]);
}
$checkGoodsName = self::isHaveSensitive($skuData["goods_name"], 1);
if ($checkGoodsName) {
throw new GoodsException(['cus' => 19]);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment