2 İşlemeler 3b4e63de58 ... 96671e7828

Yazar SHA1 Mesaj Tarih
  jace 96671e7828 Merge branch 'master' of http://alisz.titanera.com:3000/titan/CRM 6 yıl önce
  jace e3db31a588 增加撤销入金的功能 6 yıl önce

+ 21 - 0
normandcrm/admin/backend/models/DepositApi.php

@@ -89,4 +89,25 @@ class DepositApi extends BaseApi
             return $this->returnArray(0, [], $result['message']);
         }
     }
+
+    /**
+     * 撤销入金
+     * @param int $id
+     * @param int $type
+     * @param string $admin_name
+     * @return array
+     */
+    public function Revokegold($id, $mt4_id)
+    {
+        $data = [
+            'id' => $id,
+            'mt4_id' => $mt4_id,
+        ];
+        $result = $this->post($this->apiUrl . '/revokegold', $data);
+        if ($result['code'] == 1) {
+            return $this->returnArray(1, $result['data'], 'SUCCESS');
+        } else {
+            return $this->returnArray(0, [], 'FAILED');
+        }
+    }
 }

+ 17 - 0
normandcrm/admin/backend/modules/admin/controllers/DepositController.php

@@ -65,4 +65,21 @@ class DepositController extends BaseController
             return $this->asJson(['isSuccess' => false, 'msg' => '操作失败']);
         }
     }
+
+    /**
+     * 撤销入金
+     * @return \yii\web\Response
+     */
+    public function actionRevokegold()
+    {
+        $id = Yii::$app->getRequest()->post('id');
+        $mt4_id = Yii::$app->getRequest()->post('mt4_order_id');
+        $api = new DepositApi();
+        $result = $api->Revokegold($id, $mt4_id);
+        if ($result['code'] == 1) {
+            return $this->asJson(['isSuccess' => true, 'msg' => '操作成功']);
+        } else {
+            return $this->asJson(['isSuccess' => false, 'msg' => '操作失败']);
+        }
+    }
 }

+ 48 - 0
normandcrm/admin/backend/modules/admin/views/deposit/index.php

@@ -92,6 +92,11 @@ use yii\helpers\Url;
                             <button id="patchIntoGold" class="btn btn-primary">补单</button>
                         </div>
                     <?php endif;?>
+                    <?php if ($type == 1): ?>
+                        <div class="btn-group pull-right" style="margin-right: 10px;">
+                            <button id="RevokeIntoGold" class="btn btn-primary">撤销入金</button>
+                        </div>
+                    <?php endif; ?>
                     <div class="clearfix"></div>
                 </div>
                 <div class="ibox-content">
@@ -351,6 +356,49 @@ use yii\helpers\Url;
             });
         }
     });
+
+    // 撤销入金的操作
+    $('#RevokeIntoGold').click(function () {
+        var data = table.row('.selected').data();
+        if (data != undefined) {
+            swal({
+                title: "您确定吗?",
+                text: "确定撤销此订单",
+                type: "warning",
+                showCancelButton: true,
+                confirmButtonColor: "#DD6B55",
+                confirmButtonText: "确定",
+                cancelButtonText: "取消",
+                closeOnConfirm: true
+            }, function (isConfirm) {
+                if (isConfirm) {
+                    $.ajax({
+                        type: "POST",
+                        url: "<?= Url::to(['revokegold']) ?>",
+                        data: {
+                            id: data.id,
+                            mt4_order_id:data.mt4_order_id
+                        },
+                        dataType: "json",
+                        beforeSend: function () {
+                        },
+                        success: function (data) {
+                            if (data.isSuccess) {
+                                toastr.success(data.msg,'提示');
+                                table.ajax.reload();
+                            } else {
+                                toastr.error(data.msg, "提示");
+                            }
+                        },
+                        complete: function (XMLHttpRequest, textStatus) {
+                        },
+                        error: function () {
+                        }
+                    });
+                }
+            });
+        }
+    });
 </script>
 <?php $this->endBlock();?>
 

+ 54 - 0
normandcrm/service/backend/controllers/DepositController.php

@@ -14,6 +14,7 @@ use backend\models\UserMember;
 use common\helpers\MtKit;
 use common\helpers\Utils;
 use common\pay\PayForm;
+use common\lib\Mt4ManagerApi;
 use Yii;
 
 class DepositController extends BaseController
@@ -160,6 +161,59 @@ class DepositController extends BaseController
         return $this->outJson(1, [], '操作成功');
     }
 
+    /**
+     * 撤销入金
+     */
+    public function actionRevokegold(){
+
+        $id = (int) Yii::$app->request->post('id');                 //获取入金id
+        $mt4_id = (int) Yii::$app->request->post('mt4_id');         //获取mt4的订单号
+
+        file_put_contents('goldentry_id.txt',$id);
+        file_put_contents('goldentry_mt4_id.txt',$mt4_id);
+
+        if ($id <= 0) {
+            return $this->outJson(0, [], '未指定数据对象');
+        }
+        $login = Deposit::findOne($id)['login'];                    //获取login参数
+        $res = Deposit::updateAll(['type' => 0], "id = $id");       //更新入金表的状态(等待)      后续还需要更改什么
+
+        if($res){
+
+             //调用mt4的撤销入金接口
+             $api = new Mt4ManagerApi();
+             $result = $api->revokeOrder($mt4_id);
+             if(empty($result)){
+                 return $this->outJson(0, [], '更新失败');
+             }
+             $result = json_decode($result,true);
+             $tt = print_r($result,true);
+             file_put_contents('goldentry1.txt',$tt);
+             if(!$result['ret']){
+                 $result2 = $api->fixbalance($login);
+                 if(empty($result2)){
+                     return $this->outJson(0, [], '更新失败');
+                 }
+                 $res2 = json_decode($result2,true);
+                 $tt = print_r($res2,true);
+                 file_put_contents('goldentry2.txt',$tt);
+                 if(!$res2['ret']){
+                     $res3 = Deposit::updateAll(['mt4_status' => 0], "id = $id");        //更新出金表的状态(mt4未扣减)
+                     if($res3){
+                         return $this->outJson(1, [], '操作成功');
+                     }else{
+                         return $this->outJson(0, [], '更新失败');
+                     }
+                 }
+             }else{
+                 return $this->outJson(0, [], '更新失败');
+             }
+
+        }else{
+            return $this->outJson(0, [], '更新失败');
+        }
+    }
+
     /**
      * 获取入金配置
      * @return \yii\web\Response