Commit d20641ab authored by jianghaiming's avatar jianghaiming

Merge branch 'develop' of https://gitlab.yidian-inc.com/bp/goods into develop

parents 72b640d1 523222ef
......@@ -38,5 +38,6 @@ class GoodsException extends BaseException
24 => '当前商品库存不足',
25 => '开始时间格式不对',
26 => '结束时间格式不对',
27 => 'TCC调用失败',
];
}
\ No newline at end of file
<?php
namespace Validate;
/**
* Class GoodsTccCancelValidate
*
* @package Validate
*/
class GoodsTccCancelValidate extends BaseValidate
{
protected $rule = [
'tid' => 'require',
'keys' => 'require',
'type' => 'require',
];
protected $message = [
"tid" => "tcc事务id不能为空",
"keys" => "商品信息不能为空",
"type" => "类型字段不能为空",
];
}
\ No newline at end of file
<?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
<?php
use App\Base\Base;
use App\Exception\custom\GoodsException;
use \Validate\GoodsTccValidate;
use \Validate\GoodsTccIsFinishValidate;
use \Validate\GoodsTccCancelValidate;
use \App\Services\tcc\TccService;
......@@ -9,6 +12,7 @@ class TccController extends Base
{
/**
* 下单商品 tcc try
* @throws GoodsException
* @throws \App\Exception\custom\ParamException
*/
public function place_an_order_tryAction()
......@@ -16,67 +20,96 @@ class TccController extends Base
(new GoodsTccValidate())->validate();
$res = TccService::placeAnOrderTry($this->params["keys"], $this->params["tid"]);
$this->success(["result"=>$res]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
* 下单商品 tcc confirm
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
public function place_an_order_confirmAction()
{
(new GoodsTccValidate())->validate();
$res = TccService::placeAnOrderConfirm($this->params["keys"], $this->params["tid"]);
$this->success(["result"=>$res]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
* 下单商品 tcc cancel
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
public function place_an_order_cancelAction()
{
(new GoodsTccValidate())->validate();
$res = TccService::placeAnOrderCancel($this->params["keys"], $this->params["tid"]);
$this->success(["result"=>$res]);
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"]);
$this->success(["result"=>$res]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
* 取消订单单 商品tcc confirm
* @throws \App\Exception\custom\ParamException
* @throws \App\Exception\custom\ParamException
*/
public function cancel_order_confirmAction()
{
(new GoodsTccValidate())->validate();
$res = TccService::cancelOrderConfirm($this->params["keys"], $this->params["tid"]);
$this->success(["result"=>$res]);
(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"]);
$this->success(["result"=>$res]);
if ($res) {
$this->success();
} else {
throw new GoodsException(["cus" => 27]);
}
}
/**
......@@ -85,9 +118,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
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