shish hace 5 años
padre
commit
ae0d339712

+ 4 - 0
app-ghs/controllers/RechargeController.php

@@ -29,6 +29,8 @@ class RechargeController extends BaseController
         $get = Yii::$app->request->get();
         $amount = $get['amount'] ?? 500;
         $wxPay = dict::getDict('payWay', 'wxPay');
+        $shopAdmin = $this->shopAdmin;
+        $shopAdminName = $shopAdmin['name'] ?? '';
         $data = [
             'amount' => $amount,
             'payWay' => $wxPay,
@@ -37,6 +39,8 @@ class RechargeController extends BaseController
             'shopId' => $this->shopId,
             'modPrice' => 0,
             'remark' => '',
+            'shopAdminId' => $this->shopAdminId,
+            'shopAdminName' => $shopAdminName,
         ];
         $order = RechargeClass::addOrder($data, true);
         $orderSn = $order->orderSn;

+ 8 - 0
app-hd/controllers/RechargeController.php

@@ -52,6 +52,8 @@ class RechargeController extends BaseController
         ini_set('date.timezone', 'Asia/Shanghai');
         $wxPay = dict::getDict('payWay', 'wxPay');
         $price = getenv('RECHARGE_PRICE') == false ? 5980 : getenv('RECHARGE_PRICE');
+        $shopAdmin = $this->shopAdmin;
+        $shopAdminName = $shopAdmin['name'] ?? '';
         $data = [
             'amount' => $price,
             'payWay' => $wxPay,
@@ -60,6 +62,8 @@ class RechargeController extends BaseController
             'shopId' => $this->shopId,
             'modPrice' => 0,
             'remark' => '免费续期充值',
+            'shopAdminId' => $this->shopAdminId,
+            'shopAdminName' => $shopAdminName,
         ];
         $order = RechargeClass::addOrder($data, true);
         $orderSn = $order->orderSn;
@@ -114,6 +118,8 @@ class RechargeController extends BaseController
         $get = Yii::$app->request->get();
         $amount = $get['amount'] ?? 500;
         $wxPay = dict::getDict('payWay', 'wxPay');
+        $shopAdmin = $this->shopAdmin;
+        $shopAdminName = $shopAdmin['name'] ?? '';
         $data = [
             'amount' => $amount,
             'payWay' => $wxPay,
@@ -122,6 +128,8 @@ class RechargeController extends BaseController
             'shopId' => $this->shopId,
             'modPrice' => 0,
             'remark' => '',
+            'shopAdminId' => $this->shopAdminId,
+            'shopAdminName' => $shopAdminName,
         ];
         $order = RechargeClass::addOrder($data, true);
         $orderSn = $order->orderSn;

+ 3 - 4
app-pt/controllers/BaseController.php

@@ -10,7 +10,7 @@ use Yii;
 class BaseController extends PublicController
 {
 
-    public $staff, $staffId, $userId, $user;
+    public $staff, $staffId;
     public $isLogin = false;
     public $guestAccess = [];//不需要登陆的方法名
     public $validate = true;
@@ -27,15 +27,14 @@ class BaseController extends PublicController
         if (in_array($action->id, $this->guestAccess)) {
             $this->validate = true;
         } else {
-            $staff = StaffService::getById($staffId);
+            $staff = StaffService::getById($staffId, true);
             if (empty($staff)) {
                 util::logout();
             }
-            if($staff['status']==0){
+            if ($staff->status == 0) {
                 util::logout("账号已冻结");
             }
             $this->staff = $staff;
-            $this->user = $staff;
         }
         if ($this->validate == false) {
             util::notLogin();

+ 4 - 4
app-pt/controllers/MerchantController.php

@@ -19,8 +19,8 @@ class MerchantController extends BaseController
         if (!empty($style)) {
             $where['style'] = $style;
         }
-        $name = Yii::$app->request->get('name','');
-        if(!empty($name)){
+        $name = Yii::$app->request->get('name', '');
+        if (!empty($name)) {
             $where['name'] = ['like', $name];
         }
         $list = MerchantService::getMerchantList($where);
@@ -30,8 +30,8 @@ class MerchantController extends BaseController
     //获取当前登陆老板的帐号详情,官网购买套餐时使用 ssh 2020.1.11
     public function actionLoginAccount()
     {
-        $userId = $this->userId;
-        $admin = AdminService::getByCondition(['platUserId' => $userId]);
+        $staffId = $this->staffId;
+        $admin = AdminService::getByCondition(['platUserId' => $staffId]);
         if (empty($admin)) {
             util::fail('没有找到注册信息');
         }

+ 59 - 0
app-pt/controllers/RechargeController.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace pt\controllers;
+
+use biz\recharge\classes\RechargeClass;
+use biz\shop\classes\ShopClass;
+use common\components\dict;
+use common\components\util;
+use Yii;
+
+class RechargeController extends BaseController
+{
+
+    public function actionBalance()
+    {
+        $get = Yii::$app->request->get();
+        $amount = $get['amount'] ?? 0;
+        $password = $get['password'] ?? '';
+        $shopId = $get['shopId'] ?? 0;
+        if (empty($amount) || is_numeric($amount) == false) {
+            util::fail('请填写充值金额');
+        }
+        $staff = $this->staff;
+        if (password_verify($password, $staff->password) == false) {
+            util::fail('密码错误');
+        }
+        if (empty($shopId)) {
+            util::fail('请先择门店');
+        }
+        $shop = ShopClass::getLockById($shopId);
+        if (empty($shop)) {
+            util::fail('请先择门店!');
+        }
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $wxPay = dict::getDict('payWay', 'unknown');
+            $data = [
+                'amount' => $amount,
+                'payWay' => $wxPay,
+                'sjId' => $shop->merchantId,
+                'sjStyle' => $shop->ptStyle,
+                'shopId' => $shopId,
+                'modPrice' => 0,
+                'remark' => '',
+            ];
+            $order = RechargeClass::addOrder($data, true);
+            $tx = dict::getDict('yeTx', 'canNot');
+            $capitalType = dict::getDict('capitalType', 'xhRecharge');
+            ShopClass::addBalance($shop, $amount, $order, $tx, $capitalType);
+            $transaction->commit();
+            util::complete();
+        } catch (\Exception $exception) {
+            Yii::info("shopId:{$shopId}充值{$amount}元,系统操作失败:" . $exception->getMessage());
+            util::fail('操作失败');
+        }
+    }
+
+}

+ 5 - 1
biz/pt/classes/PtAssetClass.php

@@ -41,6 +41,10 @@ class PtAssetClass extends BaseClass
         }
 
         $id = $order->id;
+        $event = "【{$shop->merchantName} {$shop->shopName}】 充值{$amount}元 订单号:{$order->orderSn}";
+        if ($order->shopAdminId == 0) {
+            $event = "系统为【{$shop->merchantName} {$shop->shopName}】 充值{$amount}元 订单号:{$order->orderSn}";
+        }
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
@@ -49,7 +53,7 @@ class PtAssetClass extends BaseClass
             'txBalance' => $currentTxBalance,
             'io' => 1,
             'payWay' => $order->payWay,
-            'event' => "【{$shop->merchantName} {$shop->shopName}】 充值{$amount}元 订单号:{$order->orderSn}",
+            'event' => $event,
             'sjId' => $order->sjId,
             'shopId' => $order->shopId,
             'tx' => $tx,

+ 5 - 1
biz/shop/classes/ShopClass.php

@@ -168,6 +168,10 @@ class ShopClass extends BaseClass
 
         //增加余额变动记录
         $id = $order->id;
+        $event = "充值{$amount}元";
+        if ($order->shopAdminId == 0) {
+            $event = "系统充值{$amount}元";
+        }
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
@@ -176,7 +180,7 @@ class ShopClass extends BaseClass
             'txBalance' => $currentTx,
             'io' => 1,
             'payWay' => $order->payWay,
-            'event' => "充值{$amount}元",
+            'event' => $event,
             'sjId' => $order->sjId,
             'shopId' => $order->shopId,
             'tx' => $tx,

+ 7 - 7
common/components/dict.php

@@ -67,9 +67,9 @@ class dict
         'riseTypeName' => [0 => '不涨价', 1 => '按百分比', 2 => '按金额'],
 
         //支付方式
-        'payWay' => ['wxPay' => 0, 'alipay' => 1, 'balancePay' => 2, 'debtPay' => 3],
-        'payWayName' => [0 => '微信', 1 => '支付宝', 2 => '余额', 3 => '欠款'],
-        'payWayFullName' => [0 => '微信支付', 1 => '支付宝', 2 => '余额支付', 3 => '欠款支付'],
+        'payWay' => ['wxPay' => 0, 'alipay' => 1, 'balancePay' => 2, 'debtPay' => 3, 'unknown' => 9],
+        'payWayName' => [0 => '微信', 1 => '支付宝', 2 => '余额', 3 => '欠款', 9 => '未知'],
+        'payWayFullName' => [0 => '微信支付', 1 => '支付宝', 2 => '余额支付', 3 => '欠款支付', 9 => '未知'],
         //后台支付方式选项
         'htPayWayOption' => [
             ['name' => '微信', 'id' => 0],
@@ -215,10 +215,10 @@ class dict
         ],
 
         //来源
-        'fromType'=>[
-            'shop'=>1, //门店
-            'mall'=>2, //商城
-            'friend'=>3,// 朋友圈
+        'fromType' => [
+            'shop' => 1, //门店
+            'mall' => 2, //商城
+            'friend' => 3,// 朋友圈
         ]
     ];
 

+ 3 - 1
sql.sql

@@ -2630,4 +2630,6 @@ ALTER TABLE xhShop ADD sjStyle TINYINT NOT NULL DEFAULT 1 COMMENT '商家类型
 ALTER TABLE xhShop CHANGE sjStyle ptStyle TINYINT NOT NULL DEFAULT 1 COMMENT '所属平台 1花店 2供货商 请查看dict.php';
 INSERT INTO xhPtAsset VALUES(1,'零售平台余额',0.00),(2,'供货商平台余额',0.00),(3,'零售平台可提现余额',0.00),(4,'供货商平台可提现余额',0.00);
 ALTER TABLE xhPtYeChange MODIFY `tx` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '本条变动的余额 1不可提现 2可提现 请查看dict.php yeTx';
-ALTER TABLE xhShopYeChange MODIFY `tx` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '本条变动的余额 1不可提现 2可提现 请查看dict.php yeTx';
+ALTER TABLE xhShopYeChange MODIFY `tx` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '本条变动的余额 1不可提现 2可提现 请查看dict.php yeTx';
+ALTER TABLE xhRecharge ADD shopAdminId INT NOT NULL DEFAULT 0 COMMENT '员工id' AFTER `totalRecharge`;
+ALTER TABLE xhRecharge ADD shopAdminName VARCHAR(50) NOT NULL DEFAULT '' COMMENT '员工名称' AFTER `shopAdminId`;