Browse Source

Merge branch 'master' of http://gits.hdlkeji.com:3000/zhangguidong/chuyu

Cherry 2 years ago
parent
commit
04f11a46dd

+ 1 - 1
application/api/controller/Chuyutimedtask.php

@@ -87,7 +87,7 @@ class Chuyutimedtask extends Api
     public function order_sms($data){
         $TemplateCode = "SMS_262400702";
         $phoneNumber = $data['mobile'];
-        $TemplateParam = json_encode(['code' => $data['score']]);
+        $TemplateParam = json_encode(['number' => $data['score']]);
         $this->SmsTemplate($TemplateCode, $phoneNumber, $TemplateParam);
     }
     /**

+ 13 - 2
application/api/controller/Index.php

@@ -2,6 +2,7 @@
 
 namespace app\api\controller;
 
+use Alicode\Alisms;
 use app\admin\model\Banner;
 use app\common\controller\Api;
 
@@ -46,9 +47,19 @@ class Index extends Api
         $this->success('积分规则',$data);
     }
     public function order_sms(){
-        $MODEL = new Chuyutimedtask();
         $data=['mobile'=>'15588500892','score'=>100];
-        $MODEL->order_sms($data);
+        $TemplateCode = "SMS_262400702";
+        $phoneNumber = $data['mobile'];
+        $TemplateParam = json_encode(['number' => $data['score']]);
+        $sendSmsRequest = [
+            "TemplateCode" => $TemplateCode,
+            "phoneNumber" => $phoneNumber,
+            "TemplateParam" => $TemplateParam
+        ];
+
+        $res = Alisms::sendSmsCode($sendSmsRequest);
+        print_r($res);
+
     }
 
 }

+ 4 - 2
application/api/controller/Notify.php

@@ -53,15 +53,17 @@ class Notify extends Api
             if ($message['return_code'] === 'SUCCESS') { // return_code 表示通信状态,不代表支付状态
                 // 用户是否支付成功
                 if ($message ['result_code'] === 'SUCCESS') {
-                    $username = $user_model->where('id',$order['user_id'])->value('username');
+                    $username = $user_model->where('id',$order['user_id'])->find();
                     $log_data = [
                         'user_id'=>$order['user_id'],
-                        'username'=>$username,
+                        'username'=>$username['username'],
                         'money'=>$order['price'],
                         'desc'=>'商城购物支付',
                         'create_time'=>time()
                     ];
                     $transaction_log_model->insert($log_data);
+                    $sms_model = new Chuyutimedtask();
+                    $sms_model->order_sms(['mobile'=>$username['mobile'],'score'=>$username['score']]);
                     $pay_model->save(['status'=>2,'pay_time'=>time()],['pay_no'=>$message['out_trade_no']]);
                     $order_model->save(['status'=>2],['pay_no'=>$message['out_trade_no']]);
                     // 用户支付失败

+ 2 - 0
application/api/controller/Order.php

@@ -89,6 +89,8 @@ class Order extends Api
         try {
             $tableware_order_model->insertGetId($data);
             $tableware_model->isUpdate(true,['id'=>$input['tableware_id']])->save(['stock'=>$tableware_info['stock']-$input['num']]);
+            $sms_model = new Chuyutimedtask();
+            $sms_model->order_sms(['mobile'=>$this->auth->mobile,'score'=>$this->auth->score]);
             Db::commit();
             $this->success('订单创建成功');
         }catch (Exception $e){