Browse Source

Merge branch 'master' of http://git.huxiukeji.com/lizhen/lanjingling

lizhen_gitee 1 year ago
parent
commit
fd21e7fd18

+ 7 - 3
application/api/controller/Pay.php

@@ -251,7 +251,7 @@ class Pay extends Api
             $params = [
                 'type'         => $pay_type,
                 'orderid'      => $data['out_trade_no'],
-                'title'        => '充值',
+                'title'        => '余额充值',
                 'amount'       => $data['order_amount'],
                 'method'       => $platform,
                 'openid'       => $openid,
@@ -290,6 +290,9 @@ class Pay extends Api
             Db::rollback();
             return false;
         }
+        //赠送优惠券
+        $rechargeGiftWhere['config_id'] = $orderInfo['table_id'];
+        //$rechargeGift = Db::name('')->where($rechargeGiftWhere)->select();
         $userWalletWhere['user_id'] = $orderInfo['user_id'];
         $userWalletWhere['company_id'] = $orderInfo['company_id'];
         $userWalletData = Db::name('user_wallet')->where($userWalletWhere)->find();
@@ -297,7 +300,7 @@ class Pay extends Api
         $changeValue = bcadd($orderInfo['order_amount'],$orderInfo['gift_amount'],2);
         $remain = bcadd($before,$changeValue,2);
         $time = time();
-        //逻辑开始
+        //逻辑开始 记录充值明细
         $userMoneyLogData = [
             'user_id'      => $orderInfo['user_id'],
             'company_id'   => $orderInfo['company_id'],
@@ -307,13 +310,14 @@ class Pay extends Api
             'remain'       => $remain, //剩余金额
             'table'        => 'pay_order', //数据来源
             'table_id'     => $orderInfo['id'], //数据来源ID
-            'remark'       => '充值', //remark
+            'remark'       => '余额充值', //remark
             'createtime'   => $time,
         ];
         $userMoneyLogRes = Db::name('user_money_log')->insertGetId($userMoneyLogData);
         if (!$userMoneyLogRes) {
             throw new Exception('充值记录失败');
         }
+        //更新钱包余额
         $update = [
             'money' => $remain,
             'updatetime' => $time,

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

@@ -518,7 +518,7 @@ class User extends Api
         }
 
         $config = config('user_wxMiniProgram');
-        $getopenid_url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$config['appid'].'&secret='.$config['appsecret'].'&js_code='.$code.'&grant_type=authorization_code';
+        $getopenid_url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$config['appid'].'&secret='.$config['secret'].'&js_code='.$code.'&grant_type=authorization_code';
 
         $openidInfo = httpRequest($getopenid_url, 'GET');//$this->getJson($getopenid_url);
         $openidInfo = json_decode($openidInfo,true);

+ 6 - 13
application/api/controller/UserMoneyLog.php

@@ -25,26 +25,19 @@ class UserMoneyLog extends Api
     public function getList()
     {
         try {
-            $status = $this->request->param('status',1);//状态:1待使用,2已失效
             $userId = $this->auth->id;
             $companyId = $this->auth->company_id;
-            $field = 'id,coupon_name,coupon_info,endtime,number,remain';
+            $field = 'id,before,change_value,remain,remark,createtime';
             $where['user_id'] = $userId;
             $where['company_id'] = $companyId;
-            $whereOr = [];
-            if ($status == 1) {
-                $where['remain'] = ['gt',0];
-            } else {
-                $whereOr['remain'] = ['elt',0];
-                $whereOr['endtime'] = ['lt',time()];
-            }
-            $result = $this->model->field($field)->where($where)->where(function($query) use ($whereOr){
-                $query->whereOr($whereOr);
-            })->order('createtime desc')->autopage()->select();
+            $result = $this->model->field($field)->where($where)->order('createtime desc')->autopage()->select();
 
             if (!empty($result)) {
                 foreach ($result as $key => &$value) {
-                    !empty($value['endtime']) && $value['endtime'] = date('Y.m.d H:i:s',$value['endtime']);
+                    $symbol = $value['remain'] > $value['before'] ? '+' : '-';
+                    $value['symbol'] = $value['remain'] > $value['before'] ? 2 : 1;
+                    $value['change_value_text'] = $symbol.$value['change_value'];
+                    !empty($value['createtime']) && $value['createtime'] = date('Y.m.d H:i:s',$value['createtime']);
                 }
             }
             $this->success('获取成功',$result);