From b27f40cddd4870094b9635817fd39b4e6872363f Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sun, 31 Mar 2024 01:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E4=BF=AE=E6=94=B9=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/controller/Coupon.php | 17 +- addons/shopro/controller/goods/Goods.php | 37 +- addons/shopro/listener/Commission.php | 7 +- addons/shopro/service/CommissionScoreLog.php | 73 ++-- addons/shopro/service/Wallet.php | 3 +- addons/shopro/service/order/OrderCreate.php | 7 + application/admin/command/UserLevel.php | 236 +++++++++++ application/admin/controller/ScoreLog.php | 1 + .../admin/controller/shopro/Coupon.php | 9 +- .../controller/shopro/commission/Level.php | 14 +- application/admin/model/Warehouse.php | 2 + application/admin/model/shopro/Coupon.php | 66 ++- .../admin/model/shopro/order/Order.php | 13 +- .../admin/model/shopro/order/OrderItem.php | 5 +- .../shopro/order/traits/OrderItemStatus.php | 3 + .../model/shopro/order/traits/OrderStatus.php | 14 +- .../admin/model/shopro/user/WalletLog.php | 3 +- .../admin/view/shopro/config/index.html | 380 +++++++++--------- .../admin/view/shopro/coupon/index.html | 20 +- .../admin/view/shopro/goods/goods/add.html | 20 +- .../admin/view/shopro/goods/goods/select.html | 7 +- public/assets/js/backend/shopro/config.js | 6 +- .../assets/js/backend/shopro/goods/goods.js | 37 +- 23 files changed, 666 insertions(+), 314 deletions(-) create mode 100755 application/admin/command/UserLevel.php diff --git a/addons/shopro/controller/Coupon.php b/addons/shopro/controller/Coupon.php index 388f6d9..d881c32 100755 --- a/addons/shopro/controller/Coupon.php +++ b/addons/shopro/controller/Coupon.php @@ -122,12 +122,20 @@ class Coupon extends Common 'programme_2' => [], ]; if($data['coupon_rules']['programme_1']) { - $result['programme_1'] = $data['coupon_rules']['programme_1']; - $coupon_ids = array_merge($coupon_ids, array_column($data['coupon_rules']['programme_1'], 'id')); + //查询一下优惠券是否被删除 + $coupons = CouponModel::whereIn('id', array_column($data['coupon_rules']['programme_1'], 'id'))->select(); + if(!empty($coupons)) { + $coupon_ids = array_merge($coupon_ids, array_column($coupons, 'id')); + $result['programme_1'] = $coupons; + } + } if ($data['coupon_rules']['programme_2']) { - $result['programme_2'] = $data['coupon_rules']['programme_2']; - $coupon_ids = array_merge($coupon_ids, array_column($data['coupon_rules']['programme_2'], 'id')); + $coupons = CouponModel::whereIn('id', array_column($data['coupon_rules']['programme_2'], 'id'))->select(); + if(!empty($coupons)) { + $coupon_ids = array_merge($coupon_ids, array_column($coupons, 'id')); + $result['programme_2'] = $coupons; + } } $coupon_ids = array_values(array_unique($coupon_ids)); @@ -135,6 +143,7 @@ class Coupon extends Common ->where('user_id', $user_id) ->whereIn('coupon_id', $coupon_ids) ->select(); + if ($coupon_list) { $is_get = 1; } diff --git a/addons/shopro/controller/goods/Goods.php b/addons/shopro/controller/goods/Goods.php index 3c112e6..8e46534 100755 --- a/addons/shopro/controller/goods/Goods.php +++ b/addons/shopro/controller/goods/Goods.php @@ -246,25 +246,28 @@ class Goods extends Common $user = auth_user(); $user_id = $user->id; $goods_id = $this->request->param('goods_id'); - if ($goods_id) { + if(!$goods_id) { + $this->error('参数异常'); + } + + $goods_info = \app\admin\model\shopro\goods\Goods::get($goods_id); + if (empty($goods_info)) { + $this->error('商品不存在'); + } + + if ($goods_info['is_new_user'] == 1) { $user_level = Agent::where('user_id', $user_id)->value('level'); - $goods_info = \app\admin\model\shopro\goods\Goods::get($goods_id); - if (!empty($goods_info)) { - if ($goods_info['is_new_user'] == 1) { - if ($user_level != 1 ) { - $this->error('你无发购买新人大礼包', [], 100); - } - - $new_order = Order::with(['items' => function($query) use($goods_id) { - $query->where('goods_id', $goods_id); - }])->where('user_id', $user_id) - ->find(); - if ($new_order) { - $this->error('您已经购买过新人大礼包了', [], 200); - } - } - $this->success('当前商品不是新人大礼包', []); + if ($user_level != 1 ) { + $this->error('当前等级不能购买新人大礼包'); + } + + $is_buy_new_goods = $user->is_buy_new_goods; + if ($is_buy_new_goods) { + $this->error('您已经购买过新人大礼包了', [], 100); + } else { + $this->success('success', [], 100); } } + $this->success('success', []); } } diff --git a/addons/shopro/listener/Commission.php b/addons/shopro/listener/Commission.php index dc48c5a..6df9e9c 100755 --- a/addons/shopro/listener/Commission.php +++ b/addons/shopro/listener/Commission.php @@ -8,6 +8,7 @@ use addons\shopro\service\commission\Order as OrderService; use addons\shopro\service\commission\Reward as RewardService; use addons\shopro\service\commission\Agent as AgentService; use app\admin\model\shopro\Share as ShareModel; +use think\Db; class Commission { @@ -76,7 +77,11 @@ class Commission foreach ($items as $item) { // 异步执行积分结算计划 - $CommissionScoreLog->agentScoreSettlePlan($item); + Db::transaction(function () use ($CommissionScoreLog, $item) { + \think\Log::info('当前分销商订单数据=' . json_encode($item)); + $CommissionScoreLog->agentScoreSettlePlan($item); + }); + if (isset($item['ext']['is_commission']) && !$item['ext']['is_commission']) continue; diff --git a/addons/shopro/service/CommissionScoreLog.php b/addons/shopro/service/CommissionScoreLog.php index 0f702f5..9c15326 100644 --- a/addons/shopro/service/CommissionScoreLog.php +++ b/addons/shopro/service/CommissionScoreLog.php @@ -72,9 +72,15 @@ class CommissionScoreLog } /** - * 用户返积分计划 + * @param $order object 订单信息 + * @param $currentAgent object 当前分销商 + * @param $currentCommissionLevel int 循环层数 + * @param $initLevel int 初始等级 + * @param $level5 int 高级 + * @param $sonLevel int 儿子等级 + * @return true */ - public function userBackScorePlan($order, $currentAgent, $currentCommissionLevel, $initLevel, $level5) { + public function userBackScorePlan($order, $currentAgent, $currentCommissionLevel, $initLevel, $level5, $sonLevel=0) { \think\Log::info('当前分销商等级=' . $initLevel . '] ---start'.'---高级分销商---'.$level5); \think\Log::info('当前分销商订单信息=' . json_encode($order) . '] ---start'.'---高级分销商---'.$level5.'---循环次数---'.$currentCommissionLevel); @@ -85,16 +91,22 @@ class CommissionScoreLog } $parentUserId = $currentAgent->getParentUserId(); $currentLevel = $this->getAgentLevel($currentAgent); + //当前等级商品价格 $current_level_price = $this->getGoodPriceByLevel($order['goods_id'], $currentLevel)[0]; + //公司商品价格 $company_level_price = $this->getGoodPriceByLevel($order['goods_id'], self::LEVEL_6)[0]; \think\Log::info('上级分销商ID=' . $parentUserId . '] ---start'.'---高级分销商---'.$level5.'---循环次数---'.$currentCommissionLevel); - //非用户角色下单立即反积分 + //1.非用户角色下单立即反积分 并且给公司账户返积分 if ($initLevel > self::LEVEL_1 && $currentCommissionLevel == 1) { $amount = bcsub($order['goods_price'], $current_level_price, 2); //算积分 Wallet::change($currentAgent->user->id, 'score', $amount, 'back_score', [], '下单返现'); - $this->calcCompany($current_level_price, $company_level_price); + //如果没有上级 给公司账户返积分 + if(empty($parentUserId)) { + $this->calcCompany($current_level_price, $company_level_price); + } + } // 执行下一级返现任务 if ($parentUserId) { @@ -106,37 +118,40 @@ class CommissionScoreLog $parent_level_price = $this->getGoodPriceByLevel($order['goods_id'], $parentLevel)[0]; $is_new_user = $this->getGoodPriceByLevel($order['goods_id'], $parentLevel)[1]; - //新人大礼包商品不用计算返积分 给用户升级 + //2.新人大礼包商品不用计算返积分 直接给用户升级 if ($is_new_user == 1 && $initLevel == self::LEVEL_1) { -// $currentAgent->level = self::LEVEL_2; -// $currentAgent->save(); + $currentAgent_user = AgentModel::where('user_id', $this->user->id)->find(); + $currentAgent_user->level = self::LEVEL_2; + $currentAgent_user->save(); + //更新用户标识 + $this->user->is_buy_new_goods = 1; + $this->user->save(); return true; } //只有上级分销等级 比初始高才算佣金 if ($parentLevel > $initLevel) { - //1.会员不参与反佣 - if ($parentLevel == self::LEVEL_2) { - return true; - } - - - //3.向上反佣金 - if ($parentLevel > $currentLevel) { - $amount = bcsub($current_level_price, $parent_level_price, 2); - \think\Log::info('上级商品价格'.$parent_level_price); - \think\Log::info('当前商品价格'.$current_level_price); - if (!empty($amount) && $amount> 0) { - $this->calcCompany($parent_level_price, $company_level_price); - //算积分 - Wallet::change($parentAgent->user->id, 'score', $amount, 'team_order', [], '团队下单'); + //3.会员不参与反佣 + if ($parentLevel != self::LEVEL_2) { + //4.向上反佣金 + if ($parentLevel > $currentLevel) { + $amount = bcsub($current_level_price, $parent_level_price, 2); + //如果当前当前用户等级是会员 按原价算 + if($currentLevel == self::LEVEL_2) { + $amount = bcsub($order['goods_price'], $parent_level_price, 2); + } + \think\Log::info('上级商品价格'.$parent_level_price); + \think\Log::info('当前商品价格'.$current_level_price); + if (!empty($amount) && $amount> 0) { + //算积分 + Wallet::change($parentAgent->user->id, 'score', $amount, 'team_order', [], '团队下单'); + } } } - } - //4.用户的上上级是高级 算团队2% + //5.用户的上上级是高级 算团队2% 并给公司账户加钱 if ($parentLevel == self::LEVEL_5 && $currentLevel == self::LEVEL_5 && $level5<2) { if ($level5 == 0) { @@ -148,15 +163,21 @@ class CommissionScoreLog $level5++; } + + // 递归执行下一次 $currentCommissionLevel++; if ($parentAgent) { - $this->userBackScorePlan($order, $parentAgent, $currentCommissionLevel, $initLevel, $level5); + $this->userBackScorePlan($order, $parentAgent, $currentCommissionLevel, $initLevel, $level5, $currentLevel); } else { return true; } } else { + //6.只有最后一级是高级时反公司积分 + if ($currentLevel == self::LEVEL_5 && $sonLevel != self::LEVEL_5 && $currentCommissionLevel > 1) { + $this->calcCompany($current_level_price, $company_level_price); + } return true; } return true; @@ -200,8 +221,6 @@ class CommissionScoreLog if ($parentUserId) { $this->createAsyncAgentUpgradeNew($parentUserId, $order); } - return false; - } diff --git a/addons/shopro/service/Wallet.php b/addons/shopro/service/Wallet.php index ba7551a..b4d3b40 100755 --- a/addons/shopro/service/Wallet.php +++ b/addons/shopro/service/Wallet.php @@ -60,7 +60,8 @@ class Wallet 'memo' => $memo, 'ext' => $ext, 'oper_type' => $oper['type'], - 'oper_id' => $oper['id'] +// 'oper_id' => $oper['id'] + 'oper_id' => $user->id ]); // 钱包和积分记录存到 fastadmin 钱包积分记录表 diff --git a/addons/shopro/service/order/OrderCreate.php b/addons/shopro/service/order/OrderCreate.php index 31472e5..bd63c44 100755 --- a/addons/shopro/service/order/OrderCreate.php +++ b/addons/shopro/service/order/OrderCreate.php @@ -243,6 +243,13 @@ class OrderCreate $goods_sku_price_id = $buyInfo['goods_sku_price_id']; $goods_num = $buyInfo['goods_num'] ?? 1; + //如果商品是新人大礼包商品 提示用户 + if($goods['is_new_user']) { + if($this->user->is_buy_new_goods == 1) { + $this->exception('你已经购买过新人大礼包'); + } + } + // 最少购买一件 $buyInfo['goods_num'] = intval($goods_num) < 1 ? 1 : intval($goods_num); diff --git a/application/admin/command/UserLevel.php b/application/admin/command/UserLevel.php new file mode 100755 index 0000000..b2a4f0e --- /dev/null +++ b/application/admin/command/UserLevel.php @@ -0,0 +1,236 @@ +setName('level_up') + ->setDescription('用户升级'); + //要执行的controller必须一样,不适用模糊查询 + } + + protected function execute(Input $input, Output $output) + { + + $output->info("Build Successed!"); + } + + /** + * 递归扫描文件夹 + * @param string $dir + * @return array + */ + public function scandir($dir) + { + $result = []; + $cdir = scandir($dir); + foreach ($cdir as $value) { + if (!in_array($value, array(".", ".."))) { + if (is_dir($dir . DS . $value)) { + $result[$value] = $this->scandir($dir . DS . $value); + } else { + $result[] = $value; + } + } + } + return $result; + } + + /** + * 导入规则节点 + * @param array $dirarr + * @param array $parentdir + * @return array + */ + public function import($dirarr, $parentdir = []) + { + $menuarr = []; + foreach ($dirarr as $k => $v) { + if (is_array($v)) { + //当前是文件夹 + $nowparentdir = array_merge($parentdir, [$k]); + $this->import($v, $nowparentdir); + } else { + //只匹配PHP文件 + if (!preg_match('/^(\w+)\.php$/', $v, $matchone)) { + continue; + } + //导入文件 + $controller = ($parentdir ? implode('/', $parentdir) . '/' : '') . $matchone[1]; + $this->importRule($controller); + } + } + + return $menuarr; + } + + protected function importRule($controller) + { + $controller = str_replace('\\', '/', $controller); + if (stripos($controller, '/') !== false) { + $controllerArr = explode('/', $controller); + end($controllerArr); + $key = key($controllerArr); + $controllerArr[$key] = ucfirst($controllerArr[$key]); + } else { + $key = 0; + $controllerArr = [ucfirst($controller)]; + } + $classSuffix = Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''; + $className = "\\app\\admin\\controller\\" . implode("\\", $controllerArr) . $classSuffix; + + $pathArr = $controllerArr; + array_unshift($pathArr, '', 'application', 'admin', 'controller'); + $classFile = ROOT_PATH . implode(DS, $pathArr) . $classSuffix . ".php"; + $classContent = file_get_contents($classFile); + $uniqueName = uniqid("FastAdmin") . $classSuffix; + $classContent = str_replace("class " . $controllerArr[$key] . $classSuffix . " ", 'class ' . $uniqueName . ' ', $classContent); + $classContent = preg_replace("/namespace\s(.*);/", 'namespace ' . __NAMESPACE__ . ";", $classContent); + + //临时的类文件 + $tempClassFile = __DIR__ . DS . $uniqueName . ".php"; + file_put_contents($tempClassFile, $classContent); + $className = "\\app\\admin\\command\\" . $uniqueName; + + //删除临时文件 + register_shutdown_function(function () use ($tempClassFile) { + if ($tempClassFile) { + //删除临时文件 + @unlink($tempClassFile); + } + }); + + //反射机制调用类的注释和方法名 + $reflector = new ReflectionClass($className); + + //只匹配公共的方法 + $methods = $reflector->getMethods(ReflectionMethod::IS_PUBLIC); + $classComment = $reflector->getDocComment(); + //判断是否有启用软删除 + $softDeleteMethods = ['destroy', 'restore', 'recyclebin']; + $withSofeDelete = false; + $modelRegexArr = ["/\\\$this\->model\s*=\s*model\(['|\"](\w+)['|\"]\);/", "/\\\$this\->model\s*=\s*new\s+([a-zA-Z\\\]+);/"]; + $modelRegex = preg_match($modelRegexArr[0], $classContent) ? $modelRegexArr[0] : $modelRegexArr[1]; + preg_match_all($modelRegex, $classContent, $matches); + if (isset($matches[1]) && isset($matches[1][0]) && $matches[1][0]) { + \think\Request::instance()->module('admin'); + $model = model($matches[1][0]); + if (in_array('trashed', get_class_methods($model))) { + $withSofeDelete = true; + } + } + //忽略的类 + if (stripos($classComment, "@internal") !== false) { + return; + } + preg_match_all('#(@.*?)\n#s', $classComment, $annotations); + $controllerIcon = 'fa fa-circle-o'; + $controllerRemark = ''; + //判断注释中是否设置了icon值 + if (isset($annotations[1])) { + foreach ($annotations[1] as $tag) { + if (stripos($tag, '@icon') !== false) { + $controllerIcon = substr($tag, stripos($tag, ' ') + 1); + } + if (stripos($tag, '@remark') !== false) { + $controllerRemark = substr($tag, stripos($tag, ' ') + 1); + } + } + } + //过滤掉其它字符 + $controllerTitle = trim(preg_replace(array('/^\/\*\*(.*)[\n\r\t]/u', '/[\s]+\*\//u', '/\*\s@(.*)/u', '/[\s|\*]+/u'), '', $classComment)); + + //导入中文语言包 + \think\Lang::load(dirname(__DIR__) . DS . 'lang/zh-cn.php'); + + //先导入菜单的数据 + $pid = 0; + foreach ($controllerArr as $k => $v) { + $key = $k + 1; + //驼峰转下划线 + $controllerNameArr = array_slice($controllerArr, 0, $key); + foreach ($controllerNameArr as &$val) { + $val = strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $val), "_")); + } + unset($val); + $name = implode('/', $controllerNameArr); + $title = (!isset($controllerArr[$key]) ? $controllerTitle : ''); + $icon = (!isset($controllerArr[$key]) ? $controllerIcon : 'fa fa-list'); + $remark = (!isset($controllerArr[$key]) ? $controllerRemark : ''); + $title = $title ? $title : $v; + $rulemodel = $this->model->get(['name' => $name]); + if (!$rulemodel) { + $this->model + ->data(['pid' => $pid, 'name' => $name, 'title' => $title, 'icon' => $icon, 'remark' => $remark, 'ismenu' => 1, 'status' => 'normal']) + ->isUpdate(false) + ->save(); + $pid = $this->model->id; + } else { + $pid = $rulemodel->id; + } + } + $ruleArr = []; + foreach ($methods as $m => $n) { + //过滤特殊的类 + if (substr($n->name, 0, 2) == '__' || $n->name == '_initialize') { + continue; + } + //未启用软删除时过滤相关方法 + if (!$withSofeDelete && in_array($n->name, $softDeleteMethods)) { + continue; + } + //只匹配符合的方法 + if (!preg_match('/^(\w+)' . Config::get('action_suffix') . '/', $n->name, $matchtwo)) { + unset($methods[$m]); + continue; + } + $comment = $reflector->getMethod($n->name)->getDocComment(); + //忽略的方法 + if (stripos($comment, "@internal") !== false) { + continue; + } + //过滤掉其它字符 + $comment = preg_replace(array('/^\/\*\*(.*)[\n\r\t]/u', '/[\s]+\*\//u', '/\*\s@(.*)/u', '/[\s|\*]+/u'), '', $comment); + + $title = $comment ? $comment : ucfirst($n->name); + + //获取主键,作为AuthRule更新依据 + $id = $this->getAuthRulePK($name . "/" . strtolower($n->name)); + + $ruleArr[] = array('id' => $id, 'pid' => $pid, 'name' => $name . "/" . strtolower($n->name), 'icon' => 'fa fa-circle-o', 'title' => $title, 'ismenu' => 0, 'status' => 'normal'); + } + $this->model->isUpdate(false)->saveAll($ruleArr); + } + + //获取主键 + protected function getAuthRulePK($name) + { + if (!empty($name)) { + $id = $this->model + ->where('name', $name) + ->value('id'); + return $id ? $id : null; + } + } +} diff --git a/application/admin/controller/ScoreLog.php b/application/admin/controller/ScoreLog.php index e48aba8..d19626f 100755 --- a/application/admin/controller/ScoreLog.php +++ b/application/admin/controller/ScoreLog.php @@ -73,6 +73,7 @@ class ScoreLog extends Backend // 解析操作人信息 foreach ($walletLogs['data'] as &$log) { $log['oper'] = Operator::info($log['oper_type'], $log['oper'] ?? null); + $log['memo'] = $log['event_text']; } $result = ['total' => $walletLogs['total'], 'rows' => $walletLogs['data']]; return json($result); diff --git a/application/admin/controller/shopro/Coupon.php b/application/admin/controller/shopro/Coupon.php index 51a3798..a380528 100755 --- a/application/admin/controller/shopro/Coupon.php +++ b/application/admin/controller/shopro/Coupon.php @@ -177,12 +177,14 @@ class Coupon extends Common * 时间设置有效期一年 */ public function initCouponData($params) { - $amount = Goods::whereIn('id', $params['items'])->value('price'); + $goods = Goods::whereIn('id', $params['items'])->find(); $start_time = time(); $end_time = strtotime('+1 year', time()); + +// dd($params); $data = [ 'name' => $params['name'] ?? '', - 'description' => $params['description'] ?? '', + 'description' => $goods['title'].'-'.'优惠券', 'get_start_time' => $start_time, 'get_end_time' => $end_time, 'use_start_time' => $params['use_start_time'], @@ -192,9 +194,10 @@ class Coupon extends Common 'stock' => 10000, 'use_time_type' => 'days', 'days' => $params['days'], + 'use_scope' => $params['use_scope'], 'start_days' => $params['start_days'], 'type' => 'reduce', - 'amount' => $amount,//优惠券面值金额 + 'amount' => $goods['price'],//优惠券面值金额 'enough' => 0,//消费门槛 ]; return $data; diff --git a/application/admin/controller/shopro/commission/Level.php b/application/admin/controller/shopro/commission/Level.php index f780a73..a1f2dfb 100755 --- a/application/admin/controller/shopro/commission/Level.php +++ b/application/admin/controller/shopro/commission/Level.php @@ -80,8 +80,18 @@ class Level extends Common // dd($params); if ($params['level'] != 1) { - if (empty($params['coupon_rules']['programme_1'])) $this->error('请选择方案一'); - if (empty($params['coupon_rules']['programme_2'])) $this->error('请选择方案二'); + if (empty($params['coupon_rules']['programme_1']) && empty($params['coupon_rules']['programme_2'])) { + $this->error('至少选择一个方案'); + } + + if (empty($params['coupon_rules']['programme_1'])) { + $params['coupon_rules']['programme_1'] = []; + } + + if (empty($params['coupon_rules']['programme_2'])) { + $params['coupon_rules']['programme_2'] = []; + } + } diff --git a/application/admin/model/Warehouse.php b/application/admin/model/Warehouse.php index c492b64..1f55467 100755 --- a/application/admin/model/Warehouse.php +++ b/application/admin/model/Warehouse.php @@ -18,6 +18,8 @@ class Warehouse extends Model // 自动写入时间戳字段 protected $autoWriteTimestamp = 'integer'; + protected $dateFormat = 'Y-m-d H:i:s'; + // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = 'updatetime'; diff --git a/application/admin/model/shopro/Coupon.php b/application/admin/model/shopro/Coupon.php index 5789b3f..cc85655 100755 --- a/application/admin/model/shopro/Coupon.php +++ b/application/admin/model/shopro/Coupon.php @@ -277,41 +277,63 @@ class Coupon extends Common return UserCouponModel::where('coupon_id', $data['id'])->whereNotNull('use_time')->count(); } - - public function getUseStartTimeAttr($value, $data) { - $use_start_time = $value ? date('Y-m-d H:i:s', $value) : null; - $user_coupon_id = request()->param('user_coupon_id', 0); - if ($user_coupon_id && $data['use_time_type'] == 'days') { - // 从我领取的优惠券进详情,覆盖 状态 - $user = auth_user(); - $userCoupon = UserCouponModel::cache(60)->where('user_id', ($user ? $user->id : 0))->find($user_coupon_id); - if ($userCoupon) { - $use_start_time = date('Y-m-d H:i:s', $userCoupon->getData('createtime') + ($this->start_days * 86400)); + if ($value) { + if ($data['use_time_type'] == 'days') { + return date('Y-m-d H:i:s', $data['createtime'] + ($data['start_days'] * 86400)); } - } - return $use_start_time; + return $value; + } } public function getUseEndTimeAttr($value, $data) { - $use_end_time = $value ? date('Y-m-d H:i:s', $value) : null; - $user_coupon_id = request()->param('user_coupon_id', 0); - if ($user_coupon_id && $data['use_time_type'] == 'days') { - // 从我领取的优惠券进详情,覆盖 状态 - $user = auth_user(); - $userCoupon = UserCouponModel::cache(60)->where('user_id', ($user ? $user->id : 0))->find($user_coupon_id); - if ($userCoupon) { - $use_end_time = date('Y-m-d H:i:s', $userCoupon->getData('createtime') + (($this->start_days + $this->days) * 86400)); + if ($value) { + if ($data['use_time_type'] == 'days') { + return date('Y-m-d H:i:s', $data['createtime'] + (($data['start_days'] + $data['days']) * 86400)); } - } - return $use_end_time; + return $value; + } } + +// public function getUseStartTimeAttr($value, $data) +// { +// $use_start_time = $value ? date('Y-m-d H:i:s', $value) : null; +// $user_coupon_id = request()->param('user_coupon_id', 0); +// if ($user_coupon_id && $data['use_time_type'] == 'days') { +// // 从我领取的优惠券进详情,覆盖 状态 +// $user = auth_user(); +// $userCoupon = UserCouponModel::cache(60)->where('user_id', ($user ? $user->id : 0))->find($user_coupon_id); +// if ($userCoupon) { +// $use_start_time = date('Y-m-d H:i:s', $userCoupon->getData('createtime') + ($this->start_days * 86400)); +// } +// } +// +// return $use_start_time; +// } +// +// public function getUseEndTimeAttr($value, $data) +// { +// $use_end_time = $value ? date('Y-m-d H:i:s', $value) : null; +// $user_coupon_id = request()->param('user_coupon_id', 0); +// if ($user_coupon_id && $data['use_time_type'] == 'days') { +// // 从我领取的优惠券进详情,覆盖 状态 +// $user = auth_user(); +// $userCoupon = UserCouponModel::cache(60)->where('user_id', ($user ? $user->id : 0))->find($user_coupon_id); +// if ($userCoupon) { +// $use_end_time = date('Y-m-d H:i:s', $userCoupon->getData('createtime') + (($this->start_days + $this->days) * 86400)); +// } +// } +// +// return $use_end_time; +// } + + public function userCoupons() { $user = auth_user(); diff --git a/application/admin/model/shopro/order/Order.php b/application/admin/model/shopro/order/Order.php index 715e66b..41699a0 100755 --- a/application/admin/model/shopro/order/Order.php +++ b/application/admin/model/shopro/order/Order.php @@ -85,15 +85,16 @@ class Order extends Common { return [ 'unpaid' => '待付款', - 'paid' => '已支付', // 包括刚支付的,发货中,和已退款的,以及已完成的所有付过款的订单,不包含货到付款还未真实付款的订单 +// 'paid' => '已支付', // 包括刚支付的,发货中,和已退款的,以及已完成的所有付过款的订单,不包含货到付款还未真实付款的订单 'nosend' => '待发货', + 'nozt' => '待取货', 'noget' => '待收货', - 'refuse' => '已拒收', - 'nocomment' => '待评价', +// 'refuse' => '已拒收', +// 'nocomment' => '待评价', 'completed' => '已完成', - 'aftersale' => '售后', - 'applyRefundIng' => '申请退款', - 'refund' => '已退款', +// 'aftersale' => '售后', +// 'applyRefundIng' => '申请退款', +// 'refund' => '已退款', 'cancel' => '已取消', 'closed' => '交易关闭', // 包含货到付款,拒收的商品 ]; diff --git a/application/admin/model/shopro/order/OrderItem.php b/application/admin/model/shopro/order/OrderItem.php index 7c8de0a..a732da5 100755 --- a/application/admin/model/shopro/order/OrderItem.php +++ b/application/admin/model/shopro/order/OrderItem.php @@ -38,6 +38,8 @@ class OrderItem extends Common const DISPATCH_STATUS_SENDED = 1; // 已发货 const DISPATCH_STATUS_GETED = 2; // 已收货 + const SHOP_ZT_STATUS = 3; //待取货 + // 售后状态 const AFTERSALE_STATUS_REFUSE = -1; // 拒绝 @@ -62,7 +64,8 @@ class OrderItem extends Common self::DISPATCH_STATUS_REFUSE => '已拒收', self::DISPATCH_STATUS_NOSEND => '待发货', self::DISPATCH_STATUS_SENDED => '待收货', - self::DISPATCH_STATUS_GETED => '已收货' + self::DISPATCH_STATUS_GETED => '已收货', + self::SHOP_ZT_STATUS => '待取货', ]; } diff --git a/application/admin/model/shopro/order/traits/OrderItemStatus.php b/application/admin/model/shopro/order/traits/OrderItemStatus.php index 6cea976..c63140a 100755 --- a/application/admin/model/shopro/order/traits/OrderItemStatus.php +++ b/application/admin/model/shopro/order/traits/OrderItemStatus.php @@ -254,6 +254,9 @@ trait OrderItemStatus case OrderItem::DISPATCH_STATUS_SENDED: $status_code = 'noget'; break; + case OrderItem::SHOP_ZT_STATUS: + $status_code = 'nozt'; + break; case OrderItem::DISPATCH_STATUS_GETED: if ($data['comment_status'] == OrderItem::COMMENT_STATUS_NO) { $status_code = 'nocomment'; diff --git a/application/admin/model/shopro/order/traits/OrderStatus.php b/application/admin/model/shopro/order/traits/OrderStatus.php index 3984286..2b70f6d 100755 --- a/application/admin/model/shopro/order/traits/OrderStatus.php +++ b/application/admin/model/shopro/order/traits/OrderStatus.php @@ -119,6 +119,15 @@ trait OrderStatus $backendBtns[] = 'edit_consignee'; //修改收货地址 } + break; + case 'nozt': + $status_text = '待取货'; + $status_desc = '等待卖家自提'; + $dispatchType = $this->getItemDispatchTypes(); + if (in_array('shopZt', $dispatchType)) { + $btns[] = 'shopZt'; // 查看物流 + } + break; case 'refund_completed': $status_text = '退款完成'; @@ -223,7 +232,10 @@ trait OrderStatus } else if (in_array('noget', $statusCodes)) { // 存在待收货,就是待收货 $status_code = 'noget'; - } else if (in_array('nocomment', $statusCodes)) { + } else if (in_array('nozt', $statusCodes)) { + // 存在待评价,就是待评价 + $status_code = 'nozt'; + }else if (in_array('nocomment', $statusCodes)) { // 存在待评价,就是待评价 $status_code = 'nocomment'; } else if (in_array('commented', $statusCodes)) { diff --git a/application/admin/model/shopro/user/WalletLog.php b/application/admin/model/shopro/user/WalletLog.php index 8572805..728060e 100755 --- a/application/admin/model/shopro/user/WalletLog.php +++ b/application/admin/model/shopro/user/WalletLog.php @@ -29,7 +29,8 @@ class WalletLog extends Common 'signin' => '签到-赠送积分', 'replenish_signin' => '签到-补签', 'activity_gift' => '活动-赠送积分', - 'score_shop_pay' => '积分商城-积分支付', +// 'score_shop_pay' => '积分商城-积分支付', + 'score_shop_pay' => '积分支付', // 'order_pay' => '商城订单-积分抵扣', 'order_pay' => '积分支付', 'order_refund' => '订单退款-退还积分', diff --git a/application/admin/view/shopro/config/index.html b/application/admin/view/shopro/config/index.html index 4770cd3..c96116d 100755 --- a/application/admin/view/shopro/config/index.html +++ b/application/admin/view/shopro/config/index.html @@ -349,133 +349,133 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/admin/view/shopro/coupon/index.html b/application/admin/view/shopro/coupon/index.html index a31815c..082ece6 100755 --- a/application/admin/view/shopro/coupon/index.html +++ b/application/admin/view/shopro/coupon/index.html @@ -97,16 +97,16 @@ - - - - - - + + + + + + + + + + - - - + + + + + + + + + +