|
@@ -2,11 +2,9 @@
|
|
|
|
|
|
namespace app\index\controller;
|
|
|
|
|
|
-use addons\epay\library\Service;
|
|
|
use app\common\controller\Frontend;
|
|
|
-use app\common\model\MobileOrder;
|
|
|
-use app\common\service\SmsSend;
|
|
|
-use app\service\byte_dance\OceanEngineService;
|
|
|
+use app\common\service\OrderPaySuccService;
|
|
|
+use app\common\service\PayReturnService;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
|
@@ -21,55 +19,21 @@ class Payment extends Frontend
|
|
|
*/
|
|
|
public function notify($order_no)
|
|
|
{
|
|
|
- $check=Service::checkNotify($type);
|
|
|
- if (!$check) {
|
|
|
- echo '签名错误';
|
|
|
- return;
|
|
|
- }
|
|
|
- $data=$check->verify();
|
|
|
-
|
|
|
- $name="payment/$type/{$order_no}";
|
|
|
- user_log($name,compact('type','order_no','data'));
|
|
|
Db::startTrans();
|
|
|
- $payment=\app\common\model\Payment::where('order_no',$order_no)->lock(true)->find();
|
|
|
+ $payment=\app\common\model\Payment::where('order_no',$order_no)
|
|
|
+ ->lock(true)
|
|
|
+ ->find();
|
|
|
if(!$payment){
|
|
|
- user_log($name,"支付没找到");
|
|
|
- Db::rollback();
|
|
|
- return 'success';
|
|
|
- }
|
|
|
- if($payment['pay_time']){
|
|
|
- user_log($name,"支付已支付");
|
|
|
Db::rollback();
|
|
|
- return 'success';
|
|
|
+ $this->result([],400);
|
|
|
}
|
|
|
- $payment['pay_time']=time();
|
|
|
- if(!$payment->save()){
|
|
|
- user_log($name,"支付保存失败");
|
|
|
- Db::rollback();
|
|
|
- return '支付保存失败';
|
|
|
+ $service=new PayReturnService();
|
|
|
+ $service->setPayment($payment);
|
|
|
+ list($isPay,$succ)=$service->process();
|
|
|
+ if(!$payment['pay_time'] && $isPay){
|
|
|
+ $payment->payed();
|
|
|
}
|
|
|
Db::commit();
|
|
|
-
|
|
|
- Db::startTrans();
|
|
|
- $mobileOrder=MobileOrder::where('id',$payment['mobile_order_id'])->find();
|
|
|
- if(!$mobileOrder){
|
|
|
- user_log($name,"手机订单不存在");
|
|
|
- Db::rollback();
|
|
|
- return 'success';
|
|
|
- }
|
|
|
- try {
|
|
|
- $mobileOrder->paySuccessCallback($payment,$data,$type);
|
|
|
- Db::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
- user_log($name,$e->getMessage());
|
|
|
- Db::rollback();
|
|
|
- return $e->getMessage();
|
|
|
- }
|
|
|
- try {
|
|
|
- OceanEngineService::setQuery($payment['params']?:[])->setAddon(['order_no'=>$order_no])->shopping();
|
|
|
- }catch (\Exception $e){}
|
|
|
-
|
|
|
- echo "success";
|
|
|
- return;
|
|
|
+ return $succ;
|
|
|
}
|
|
|
}
|