Bläddra i källkod

增加撤销出金功能

jace 6 år sedan
förälder
incheckning
0d82597972

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

@@ -159,4 +159,25 @@ class WithdrawApi extends BaseApi
         ];
         return static::updateWithdraw($id, $data);
     }
+
+    /**
+     * 撤销出金
+     * @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');
+        }
+    }
 }

+ 18 - 0
normandcrm/admin/backend/modules/admin/controllers/WithdrawController.php

@@ -107,4 +107,22 @@ class WithdrawController 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 WithdrawApi();
+        $result = $api->Revokegold($id, $mt4_id);
+        if ($result['code'] == 1) {
+            return $this->asJson(['isSuccess' => true, 'msg' => '操作成功']);
+        } else {
+            return $this->asJson(['isSuccess' => false, 'msg' => '操作失败']);
+        }
+    }
+    
 }

+ 53 - 0
normandcrm/admin/backend/modules/admin/views/withdraw/index.php

@@ -82,6 +82,13 @@ use yii\helpers\Url;
                         <a href="/admin/withdraw/xls?type=${type!}" class="btn btn-primary">导出XLS</a>
                         -->
                     </div>
+
+                    <?php if ($type == 2): ?>
+                        <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">
@@ -543,5 +550,51 @@ use yii\helpers\Url;
         autoclose: true,
         format: "yyyy-mm-dd"
     });
+
+
+    // 撤销出金的操作
+    $('#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) {
+                    console.log(data);
+                    $.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) {
+                                table.ajax.reload();
+                            } else {
+                                toastr.error(data.msg, "提示");
+                            }
+                        },
+                        complete: function (XMLHttpRequest, textStatus) {
+                        },
+                        error: function () {
+                        }
+                    });
+                }
+            });
+        }
+    });
+
+    
 </script>
 <?php $this->endBlock(); ?>

+ 26 - 0
normandcrm/service/backend/controllers/WithdrawController.php

@@ -354,5 +354,31 @@ class WithdrawController extends BaseController
         $result = $mt4Deposit->withdraw($mt4Id, $usdMoney, $comment);     //缺少一个字段(没有用到这个方法)
         return $this->outJson($result['errCode'] == 0 ? 1 : 0, $result['data'], $result['errMsg']);
     }
+
+
+    
+    /**
+     * 撤销出金
+     */
+    public function actionRevokegold(){
+        $id = (int) Yii::$app->request->post('id');
+        $mt4_id = (int) Yii::$app->request->post('mt4_id');
+        file_put_contents('1009.txt',$id);
+        file_put_contents('100902.txt',$mt4_id);
+        $res = Withdraw::updateAll(['mt4_status' => 0,'type' => 1], "id = $id");    //更新出金表的状态(不通过,未扣减)
+
+        if($res){
+
+            //调用mt4的撤销出金接口
+            // $api = new Mt4ManagerApi();
+            // $api->userUpdate($mt4_id);
+            return $this->outJson(1, [], '操作成功');
+        }else{
+            return $this->outJson(0, [], '操作失败'); 
+        }
+
+
+    }
+
     
 }