Browse Source

卡券列表调整

zhangxiaobin 1 year ago
parent
commit
6f992cbcf0

+ 33 - 0
application/admin/controller/CompanyTakeCash.php

@@ -68,4 +68,37 @@ class CompanyTakeCash extends Backend
         return $this->view->fetch();
     }
 
+    /**
+     * 添加
+     */
+    public function add()
+    {
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            $params = $this->preExcludeFields($params);
+            if (!$params) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            $result = false;
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+                    $this->model->validateFailException(true)->validate($validate);
+                }
+                if (isset($params['user_id'])) {
+                    $params['order_no'] = createUniqueNo('T',$params['user_id']);
+                }
+                $result = $this->model->allowField(true)->save($params);
+            } catch (ValidateException|PDOException|Exception $e) {
+                $this->error($e->getMessage());
+            }
+            if ($result == false) {
+               $this->error(__('No rows were inserted'));
+            }
+            $this->success();
+        }
+        return $this->view->fetch();
+    }
 }

+ 9 - 3
application/admin/view/company_take_cash/add.html

@@ -1,11 +1,11 @@
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
 
-    <div class="form-group">
+    <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Order_no')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-order_no" class="form-control" name="row[order_no]" type="text">
+            <input id="c-order_no" class="form-control" name="row[order_no]" type="text" value="">
         </div>
-    </div>
+    </div>-->
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
         <div class="col-xs-12 col-sm-8">
@@ -13,6 +13,12 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('银行信息')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-bank_id" data-rule="required" min="0" data-source="company_bank/index" data-field="bank_name" class="form-control selectpage" name="row[bank_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-money" class="form-control" step="0.01" name="row[money]" type="number">

+ 1 - 1
application/admin/view/company_take_cash/edit.html

@@ -3,7 +3,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Order_no')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-order_no" class="form-control" name="row[order_no]" type="text" value="{$row.order_no|htmlentities}">
+            <input id="c-order_no" class="form-control" disabled="true" name="row[order_no]" type="text" value="{$row.order_no|htmlentities}">
         </div>
     </div>
     <div class="form-group">

+ 2 - 2
application/api/controller/Pay.php

@@ -265,9 +265,9 @@ class Pay extends Api
             $res = Service::submitOrder($params);
             Db::commit();
             if($pay_type == 'wechat'){
-                $this->success('success',json_decode($res,true));
+                $this->success('充值成功',json_decode($res,true));
             }else{
-                $this->success('success',$res);
+                $this->success('充值成功',$res);
             }
         } catch (Exception $e) {
             Db::rollback();

+ 1 - 0
application/api/controller/UserCoupons.php

@@ -34,6 +34,7 @@ class UserCoupons extends Api
             $whereOr = [];
             if ($status == 1) {
                 $where['remain'] = ['gt',0];
+                $whereOr['endtime'] = ['gt',time()];
             } else {
                 $whereOr['remain'] = ['elt',0];
                 $whereOr['endtime'] = ['lt',time()];

+ 3 - 0
public/assets/js/backend/company_take_cash.js

@@ -51,6 +51,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Table.api.bindevent(table);
         },
         add: function () {
+            $("#c-bank_id").data("params",function(){
+                return {custom:{company_id:$("#c-user_id").val()}};
+            });
             Controller.api.bindevent();
         },
         edit: function () {