...
|
...
|
@@ -23,17 +23,12 @@ class Notify extends Api |
|
|
public function orderNotify()
|
|
|
{
|
|
|
$paytype = $this->request->param('type');
|
|
|
Db::name('pay')->insert(['number'=>111,'text'=>'']);
|
|
|
$pay = Service::checkNotify($paytype);
|
|
|
if (!$pay) {
|
|
|
Db::name('pay')->insert(['number'=>222,'text'=>'']);
|
|
|
echo '签名错误';
|
|
|
return;
|
|
|
return '签名错误';
|
|
|
}
|
|
|
$data = $pay->verify();
|
|
|
if (is_array($data)) $data = json_encode($data);
|
|
|
Db::name('pay')->insert(['number'=>333,'text'=>$data]);exit();
|
|
|
$data = json_decode($data,true);
|
|
|
if (!is_array($data)) $data = json_decode($data,true);
|
|
|
$model = new \app\api\model\Order();
|
|
|
$goodsmodel = new \app\api\model\OrderGoods();
|
|
|
$skumodel = new \app\api\model\GoodsSpec();
|
...
|
...
|
@@ -53,15 +48,17 @@ class Notify extends Api |
|
|
$order->isUpdate()->save();
|
|
|
// 减少库存
|
|
|
$sales_actual = 0;
|
|
|
$goods_ids = [];
|
|
|
$list = $goodsmodel->where('order_id',$order['id'])->select();
|
|
|
foreach ($list as $key => $value){
|
|
|
$goods_ids[] = $value['goods_id'];
|
|
|
$sales_actual+=$value['total_num'];
|
|
|
if ($value['deduct_stock_type'] == 20){
|
|
|
$skumodel->where('goods_spec_id',$value['goods_spec_id'])->setDec('stock_num',$value['total_num']);
|
|
|
}
|
|
|
}
|
|
|
// 增加销量
|
|
|
$goods_model->setInc('sales_actual',$sales_actual);
|
|
|
$goods_model->whereIn('goods_id',$goods_ids)->setInc('sales_actual',$sales_actual);
|
|
|
// 判断是否邀请成功
|
|
|
$user = \app\api\model\User::get($order['user_id']);
|
|
|
if ($user['invite_user_id'] > 0 && $user['invite_status'] != 1) {
|
...
|
...
|
@@ -97,7 +94,7 @@ class Notify extends Api |
|
|
$buymodel->isUpdate(false)->saveAll($data);
|
|
|
} catch (Exception $e) {
|
|
|
}
|
|
|
echo $pay->success()->send();
|
|
|
return $pay->success()->send();
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|