Commit c37e14a6 authored by luhongguang's avatar luhongguang

update:tcc 是否完成接口

parent 242532e6
<?php
namespace Validate;
/**
* Class GoodsTccIsFinishValidate
*
* @package Validate
*/
class GoodsTccIsFinishValidate extends BaseValidate
{
protected $rule = [
'tid' => 'require',
'goods_sku_id_str' => 'require',
];
protected $message = [
"tid" => "tcc事务id不能为空",
"goods_sku_id_str" => "商品sku_id不能为空",
];
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
use App\Base\Base;
use App\Exception\custom\GoodsException;
use \Validate\GoodsTccValidate;
use \Validate\GoodsTccIsFinishValidate;
use \App\Services\tcc\TccService;
......@@ -116,9 +117,9 @@ class TccController extends Base
*/
public function tcc_is_finishAction()
{
(new GoodsTccValidate())->validate();
(new GoodsTccIsFinishValidate())->validate();
$res = TccService::tccIsFinish($this->params["keys"], $this->params["tid"]);
$res = TccService::tccIsFinish($this->params["goods_sku_id_str"], $this->params["tid"]);
$this->success(["result"=>$res]);
}
}
\ No newline at end of file
......@@ -731,20 +731,21 @@ class TccService
/**
* 判断一个tcc是否完成
* @param $goodsSkuId
* @param $goodsSkuIdStr
* @param $tid
* @return int
*/
public static function tccIsFinish($goodsSkuId, $tid)
public static function tccIsFinish($goodsSkuIdStr, $tid)
{
$tccInfo = Tcc::getRecord([
$goodsSkuIds = explode(",", $goodsSkuIdStr);
$tccInfoList = Tcc::getRecordMaster([
"tid" => $tid,
"goods_sku_id" => $goodsSkuId,
"goods_sku_id" => $goodsSkuIds,
"status" => [Tcc::STATUS_CONFIRM, Tcc::STATUS_CANCEL],
"operator_result" => Tcc::OPERATOR_RESULT_SUCCESS,
]);
if (!empty($tccInfo)) {
if (!empty($tccInfoList) && count($tccInfoList) == count($goodsSkuIds)) {
return self::TCC_RESULT_SUCCESS;
}
return self::TCC_RESULT_FAIL;
......
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