Pārlūkot izejas kodu

add: 自动添加幸运属性支持番外分类,增加注册送钱活动
修改用户提现消息内容

joe 4 gadi atpakaļ
vecāks
revīzija
3afb2c98d7

+ 18 - 18
app/admin/controller/store/StoreProduct.php

@@ -142,7 +142,9 @@ class StoreProduct extends AuthController
     public function create($id = 0)
     {
         $this->assign('id', (int)$id);
-        $this->assign('lucky_id', Config::get('activity.lucky_cate_id'));
+        $luckies = get_luckies();
+        $this->assign('lucky_id', json_encode($luckies));
+        $this->assign('lucky_spec_name', Config::get('activity.lucky_spec_name') );
         return $this->fetch();
     }
 
@@ -287,6 +289,8 @@ class StoreProduct extends AuthController
                 $data['activity'][$k] = 3;
             }
         }
+        $lucky_spec_name = Config::get('activity.lucky_spec_name');
+        $lucky_spec_items = Config::get('activity.lucky_spec_items');
         $data['activity'] = implode(',', $data['activity']);
         $detail = $data['attrs'];
         $data['price'] = min(array_column($detail, 'price'));
@@ -338,15 +342,13 @@ class StoreProduct extends AuthController
                 $detail[0]['value1'] = '规格';
                 $detail[0]['detail'] = ['规格' => '默认'];
             } else {
-                if ($cate_id[0] == Config::get('activity.lucky_cate_id')) {
-                    if (!array_search('幸运', array_column($attr, 'value'))) {
+                if ( in_array($cate_id[0], get_luckies()) ) {
+                    if (!array_search($lucky_spec_name, array_column($attr, 'value'))) {
                         $attr[] = [
-                            'value' => '幸运',
+                            'value' => $lucky_spec_name,
                             'detailValue' => '',
                             'attrHidden' => '',
-                            'detail' => [
-                                20, 21
-                            ],
+                            'detail' => $lucky_spec_items,
                         ];
                     }
                 }
@@ -383,14 +385,12 @@ class StoreProduct extends AuthController
                 $detail[0]['value1'] = '规格';
                 $detail[0]['detail'] = ['规格' => '默认'];
             } else {
-                if ($cate_id[0] == Config::get('activity.lucky_cate_id')) {
+                if ( in_array($cate_id[0], get_luckies()) ) {
                     $attr[] = [
-                        'value' => '幸运',
+                        'value' => $lucky_spec_name,
                         'detailValue' => '',
                         'attrHidden' => '',
-                        'detail' => [
-                            20, 21
-                        ],
+                        'detail' => $lucky_spec_items,
                     ];
                 }
             }
@@ -548,15 +548,15 @@ class StoreProduct extends AuthController
         if (is_array($cate_id)) {
             return Json::fail('产品只能属于一个分类');
         }
-        if ($cate_id == Config::get('activity.lucky_cate_id')) {
-            if (!array_search('幸运', array_column($data['attrs'], 'value'))) {
+        $lucky_spec_name = Config::get('activity.lucky_spec_name');
+        $lucky_spec_items = Config::get('activity.lucky_spec_items');
+        if ( in_array($cate_id, get_luckies()) ) {
+            if (!array_search($lucky_spec_name, array_column($data['attrs'], 'value'))) {
                 $data['attrs'][] = [
-                    'value' => '幸运',
+                    'value' => $lucky_spec_name,
                     'detailValue' => '',
                     'attrHidden' => '',
-                    'detail' => [
-                        20, 21
-                    ],
+                    'detail' => $lucky_spec_items,
                 ];
             }
         }

+ 4 - 2
app/admin/view/store/store_product/create.php

@@ -893,6 +893,8 @@
 <script>
     var id = {$id};
     var lucky_id = {$lucky_id};
+    var lucky_spec_name = '{$lucky_spec_name}';
+
     new Vue({
         el: '#app',
         data: {
@@ -1475,7 +1477,7 @@
                 } else if (that.formData.cate_id.length > 1) {
                     return that.showMsg('商品不能属于多个分类');
                 }
-                var is_lucky = that.formData.cate_id[0] == lucky_id;
+                var is_lucky = lucky_id.includes(parseInt(that.formData.cate_id[0]));
 
                 if (!that.formData.temp_id) {
                     return that.showMsg('请选择运费模板');
@@ -1538,7 +1540,7 @@
                     // }
 
                     if(!is_lucky && that.formData.items.find(function(val) {
-                        if (val.value == '幸运') {
+                        if (val.value == lucky_spec_name) {
                             return true;
                         }
                     })) {

+ 33 - 1
app/common.php

@@ -9,6 +9,7 @@
 // | Author: 流年 <liu21st@gmail.com>
 // +----------------------------------------------------------------------
 
+use \think\facade\Config as ThinkConf;
 // 应用公共文件
 
 // 订单常量
@@ -34,6 +35,37 @@ define('DISTRIBUTE_SPECIFIED', 1);  // 指定分銷
 define('DISTRIBUTE_EVERYONE', 2);   // 人人分銷
 
 
+/**
+ * 获取所有 幸运2021 活动及其子活动 ID 列表
+ */
+function get_luckies(): Array 
+{
+    return [
+        ThinkConf::get('activity.lucky_cate_id'),
+        ThinkConf::get('activity.lucky_a_cate_id'),
+        ThinkConf::get('activity.lucky_b_cate_id'),
+    ];
+}
+
+/**
+ * 获取 提现类型, 帐号,用于日志或者消息
+ */
+function get_extract_name($extract): Array
+{
+    if (!$extract || !isset($extract['extract_type'])) {
+        return ['未知', ''];
+    }
+    switch($extract['extract_type']) {
+        case 'weixin':
+            return ['微信支付', $extract['wechat'] ?? ''];
+        case 'alipay':
+            return ['支付宝', $extract['alipay_code'] ?? ''];
+        case 'bank':
+            return [$extract['bank_address'] ?? '未知银行', $extract['bank_code'] ?? ''];
+    }
+    return ['未知', ''];
+}
+
 if (!function_exists('exception')) {
     /**
      * 抛出异常处理
@@ -223,7 +255,7 @@ if (!function_exists('set_file_url')) {
 if (!function_exists('set_http_type')) {
     /**
      * 修改 https 和 http
-     * @param $url $url 域名
+     * @param string $url 域名
      * @param int $type 0 返回https 1 返回 http
      * @return string
      */

+ 4 - 0
app/models/user/User.php

@@ -7,6 +7,7 @@ use app\models\store\StoreOrder;
 use app\models\store\StoreProduct;
 use crmeb\services\SystemConfigService;
 use think\facade\Session;
+use think\facade\Config;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 use crmeb\traits\JwtAuthModelTrait;
@@ -203,6 +204,8 @@ class User extends BaseModel
         if ($spread_uid) {
             $res1 = self::where('uid', $spread_uid)->inc('spread_count', 1)->update();
         }
+        $register_money = floatval(Config::get('activity.register_money', 0.0));
+
 //        $storeBrokerageStatu = sys_config('store_brokerage_statu') ? : 1;//获取后台分销类型
         $res2 = self::create([
             'account' => 'rt' . $routineUser['uid'] . time(),
@@ -212,6 +215,7 @@ class User extends BaseModel
             'spread_uid' => $spread_uid,
 //            'is_promoter'=>$spread_uid || $storeBrokerageStatu != 1 ? 1: 0,
             'spread_time' => $spread_uid ? time() : 0,
+            'now_money' => $register_money,
             'uid' => $routineUser['uid'],
             'add_time' => $routineUser['add_time'],
             'add_ip' => request()->ip(),

+ 5 - 0
config/activity.php

@@ -16,6 +16,9 @@ return [
     'clearance_cate_id' => 2,
     // 清仓开奖时间表
     'clearrance_daily_opens' => [],
+    // 幸运商品规格
+    'lucky_spec_name' => '幸运',
+    'lucky_spec_items' => [20, 21],
     // 幸运活动 ID
     'lucky_cate_id' => 1,
     // 幸运活动番外A ID
@@ -24,4 +27,6 @@ return [
     'lucky_b_cate_id' => 4,
     // 幸运活动开奖时间表
     'lucky_daily_opens' => [],
+    // 注册送钱
+    'register_money' => 5.0,
 ];

+ 11 - 2
crmeb/subscribes/UserSubscribe.php

@@ -6,6 +6,7 @@ use app\models\user\User;
 use app\models\user\WechatUser;
 use think\facade\Cookie;
 use app\admin\model\system\SystemAttachment;
+use app\admin\model\user\UserBill;
 use app\models\user\UserLevel;
 use app\models\user\UserNotice;
 use think\facade\Log;
@@ -140,6 +141,10 @@ class UserSubscribe
     {
         list('user' => $user) = $event;
 
+        $res = UserBill::income('新用户送钱活动', $user['uid'], 'now_money', 'brokerage', $user['now_money'], $user['uid'], $user['now_money'], '新用户送' . $user['now_money'] . '元');
+        if (!$res) {
+            Log::error('user ' . $user['uid'] . 'registered send money ' . $user['now_money'] . ' failed.');
+        }
         Log::debug('EVENT new user registered:' . $user['uid']);
     }
 
@@ -170,9 +175,11 @@ class UserSubscribe
     {
         list($extract) = $event;
         $icon = Config::get('app.header_cs_2', '');
+        list($extract_type, $account) = get_extract_name($extract);
         UserNotice::sendNoticeTo($extract['uid'], '您的提现申请已处理',
                 '您申请提现 ' . $extract['extract_price']
-                . ' 元已转账,请耐心等待收款方系统确认后核对金额。衷心感谢您对美天旺的信任和支持。如有问题,请联系客服。', $icon);
+                . ' 元到' . $extract_type . '帐号' . $account
+                . '已转账,请耐心等待您的收款账户系统确认后核对金额。衷心感谢您对美天旺的信任和支持。如有问题,请联系客服。', $icon);
     }
     /**
      * 後臺拒絕提現 UserExtractFail
@@ -181,9 +188,11 @@ class UserSubscribe
     {
         list($extract, $fail_msg) = $event;
         $icon = Config::get('app.header_cs_2', '');
+        list($extract_type, $account) = get_extract_name($extract);
         UserNotice::sendNoticeTo($extract['uid'], '您的提现申请已处理',
         '您申请提现 ' . $extract['extract_price']
-        . ' 元未能成功执行,原因:' . $fail_msg['message'] . '。请联系客服处理。', $icon);
+        . ' 元到' . $extract_type . '帐号' . $account
+        . '未能成功执行,原因:' . $fail_msg['message'] . '。请联系客服处理。', $icon);
     }
 
     /**