作者 jinglong
1 个管道 的构建 通过 耗费 5 秒

修改检索接口

... ... @@ -479,6 +479,24 @@ class Common
}
/**
* 减库存
* @ApiInternal
*/
public static function decStock($where){
$goodsModel = new \app\admin\model\Goods();
$goodsModel->where($where)->setDec('stock',1);
}
/**
* 增销量
* @ApiInternal
*/
public static function incSales($where){
$goodsModel = new \app\admin\model\Goods();
$goodsModel->where($where)->setInc('sales',1);
}
/**
* 更新优惠券
* @ApiInternal
*/
... ... @@ -488,17 +506,21 @@ class Common
}
/**
* 购买成功,更新订单号,销量增加1
* 购买成功,更新订单号为待发货,销量增加1,减库存,
* @ApiInternal
*/
public static function incSales($out_trade_no){
public static function paySuccess($out_trade_no){
$status = config('verify.status');
//更新订单号成功
$orderModel = new Order();
$orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2]]);
$goodsModel = new \app\admin\model\Goods();
//销量增加1
$res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id');
$goodsModel->where(['id'=>$res['id']])->setInc('sales',1);
if($res){
$res1 = self::selectSoftWhereData('ogoods',['o_id'=>$res['id']],'id,g_id');
$g_ids = array_column($res1,'g_id');
self::decStock(['id'=>['in',$g_ids]]);
self::incSales(['id'=>['in',$g_ids]]);
}
}
}
... ...
... ... @@ -113,7 +113,7 @@ class Pay extends Api
if ($message['result_code'] === 'SUCCESS') {
//支付成功,更新订单号,销量增加1
Common::incSales($message['out_trade_no']);
Common::paySuccess($message['out_trade_no']);
}elseif($message['result_code'] === 'FAIL') {
//支付失败
}
... ... @@ -219,7 +219,7 @@ class Pay extends Api
if ($message['return_code'] === 'SUCCESS') {
if ($message['result_code'] === 'SUCCESS') {
//支付成功,更新订单号,销量增加1
Common::incSales($message['out_trade_no']);
Common::paySuccess($message['out_trade_no']);
}elseif($message['result_code'] === 'FAIL') {
//支付失败,好像有问题
}
... ...
... ... @@ -10,7 +10,7 @@ use think\Validate;
*/
class Search extends Api
{
protected $noNeedLogin = [];
protected $noNeedLogin = ['searchGoodsList'];
protected $noNeedRight = ['*'];
protected $uid = '';
public function _initialize()
... ... @@ -24,7 +24,6 @@ class Search extends Api
* @ApiSummary (商品检索列表)
* @ApiMethod (GET)
* @ApiRoute (/api/search/searchGoodsList)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="keyword", type="string", required=true, description="检索关键字")
* @ApiParams (name="page", type="inter", required=true, description="分页页码")
... ...
... ... @@ -480,6 +480,11 @@ class User extends Api
$this->error($validate->getError());
}
if($share_uid == $this->uid){
//携带参数错误
$this->error('失败');
}
$rCouponModel = new Rcoupon();
//查询分享人已领取优惠券
$receive = Common::selectWhereData('rcoupon',['uid'=>$share_uid],'id,c_id');
... ...
... ... @@ -5823,24 +5823,7 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<table class="table table-hover">
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>token</td>
<td>string</td>
<td></td>
<td>请求的Token</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default">
... ... @@ -5883,17 +5866,6 @@
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
<div class="headers">
<div class="form-group">
<label class="control-label" for="token">token</label>
<input type="string" class="form-control input-sm" id="token" required placeholder="请求的Token - Ex: " name="token">
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/search/searchGoodsList" method="GET" name="form36" id="form36">
... ... @@ -7271,7 +7243,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2019-12-05 19:38:12 </div>
Generated on 2019-12-06 10:16:14 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...