From 45423fa76c861e98d0cd6e804fec80da9792c14f Mon Sep 17 00:00:00 2001 From: zhouzhongping Date: Fri, 16 Jul 2021 16:26:32 +0800 Subject: [PATCH] v1.1.45 --- README.md | 9 ++ doc/database/install.sql | 17 +- doc/database/upgrade/v1.1.45.sql | 17 ++ doc/更新日志.txt | 26 +++ source/application/api/controller/Cart.php | 2 +- source/application/api/controller/Goods.php | 6 +- .../api/controller/sharp/Goods.php | 4 +- source/application/api/model/UserCoupon.php | 64 ++++++-- .../api/service/order/Checkout.php | 55 +++++-- .../application/api/service/sharp/Active.php | 5 +- .../common/library/wechat/WxPay.php | 6 + source/application/common/model/Coupon.php | 30 ++++ .../application/common/model/UserCoupon.php | 21 +++ .../store/controller/apps/dealer/Withdraw.php | 9 +- .../store/controller/market/Basic.php | 14 +- .../store/controller/market/Coupon.php | 10 +- .../application/store/model/DeliveryRule.php | 40 ----- .../store/view/market/basic/full_free.php | 2 +- .../store/view/market/coupon/add.php | 120 +++++++++++++- .../store/view/market/coupon/edit.php | 148 +++++++++++++++++- .../application/store/view/passport/login.php | 18 +++ version.json | 2 +- web/assets/store/js/goods.spec.js | 89 ++++++++--- 23 files changed, 587 insertions(+), 127 deletions(-) create mode 100644 doc/database/upgrade/v1.1.45.sql diff --git a/README.md b/README.md index 846df3b..fc018ea 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,15 @@ ## 更新日志 +### v1.1.45 + +新增:优惠券支持指定商品 +新增:小程序端底部购物车数量(角标) +优化:微信退款API记录日志 +优化:整点秒杀页面倒计时结束刷新 +修复:后台满额包邮地区总数错误 +修复:后台分销商确认打款时报错 + ### v1.1.44 ``` diff --git a/doc/database/install.sql b/doc/database/install.sql index 68c3b09..727fa79 100644 --- a/doc/database/install.sql +++ b/doc/database/install.sql @@ -56,7 +56,8 @@ CREATE TABLE `yoshop_coupon` ( `expire_day` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '领取后生效-有效天数', `start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '固定时间-开始时间', `end_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '固定时间-结束时间', - `apply_range` tinyint(3) unsigned NOT NULL DEFAULT '10' COMMENT '适用范围(10全部商品 20指定商品)', + `apply_range` tinyint(3) unsigned NOT NULL DEFAULT '10' COMMENT '适用范围(10全部商品 20指定商品 30排除商品)', + `apply_range_config` text NOT NULL COMMENT '适用范围配置(json格式)', `total_num` int(11) NOT NULL DEFAULT '0' COMMENT '发放总数量(-1为不限制)', `receive_num` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '已领取数量', `sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序方式(数字越小越靠前)', @@ -68,17 +69,6 @@ CREATE TABLE `yoshop_coupon` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COMMENT='优惠券记录表'; -CREATE TABLE `yoshop_coupon_goods` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id', - `coupon_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '优惠券id', - `goods_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商品id', - `wxapp_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '小程序id', - `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COMMENT='优惠券指定商品记录表'; - - CREATE TABLE `yoshop_delivery` ( `delivery_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '模板id', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '模板名称', @@ -4200,7 +4190,8 @@ CREATE TABLE `yoshop_user_coupon` ( `expire_day` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '领取后生效-有效天数', `start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '有效期开始时间', `end_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '有效期结束时间', - `apply_range` tinyint(3) unsigned NOT NULL DEFAULT '10' COMMENT '适用范围(10全部商品 20指定商品)', + `apply_range` tinyint(3) unsigned NOT NULL DEFAULT '10' COMMENT '适用范围(10全部商品 20指定商品 30排除商品)', + `apply_range_config` text NOT NULL COMMENT '适用范围配置(json格式)', `is_expire` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否过期(0未过期 1已过期)', `is_use` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否已使用(0未使用 1已使用)', `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id', diff --git a/doc/database/upgrade/v1.1.45.sql b/doc/database/upgrade/v1.1.45.sql new file mode 100644 index 0000000..93c175f --- /dev/null +++ b/doc/database/upgrade/v1.1.45.sql @@ -0,0 +1,17 @@ + + +ALTER TABLE `yoshop_coupon` +ADD COLUMN `apply_range_config` text NOT NULL COMMENT '适用范围配置(json格式)' AFTER `apply_range`; + + +ALTER TABLE `yoshop_user_coupon` +ADD COLUMN `apply_range_config` text NOT NULL COMMENT '适用范围配置(json格式)' AFTER `apply_range`; + + +ALTER TABLE `yoshop_coupon` +MODIFY COLUMN `apply_range` tinyint(3) UNSIGNED NOT NULL DEFAULT 10 COMMENT '适用范围(10全部商品 20指定商品 30排除商品)' AFTER `end_time`; + + +ALTER TABLE `yoshop_user_coupon` +MODIFY COLUMN `apply_range` tinyint(3) UNSIGNED NOT NULL DEFAULT 10 COMMENT '适用范围(10全部商品 20指定商品 30排除商品)' AFTER `end_time`; + diff --git a/doc/更新日志.txt b/doc/更新日志.txt index 66e447b..544fca1 100644 --- a/doc/更新日志.txt +++ b/doc/更新日志.txt @@ -1,4 +1,30 @@  +### v1.1.45 更新日志 ### + +新增:优惠券支持指定商品 +新增:小程序端底部购物车数量(角标) +优化:微信退款API记录日志 +优化:整点秒杀页面倒计时结束刷新 +修复:后台满额包邮地区总数错误 +修复:后台分销商确认打款时报错 +-------------------------------- +注:本次更新须重新发布小程序 + + +### v1.1.44 更新日志 ### + +新增:小程序转发到朋友圈(灰度安卓用户) +优化:微信打款时验证冻结资金是否合法 +优化:mysql报错时记录Error SQL +修复:后台权限缺少文件列表和回收站 +修复:地区表中部分地区不存在 +修复:获取直播房间列表接口报错 +修复:后台订单详情页报错 +修复:小程序端富文本视频高度不生效 +-------------------------------- +注:本次更新须重新发布小程序 + + ### v1.1.43 更新日志 ### 优化:mysql5.7环境数据排序问题 diff --git a/source/application/api/controller/Cart.php b/source/application/api/controller/Cart.php index 86d2796..41ba733 100644 --- a/source/application/api/controller/Cart.php +++ b/source/application/api/controller/Cart.php @@ -66,7 +66,7 @@ class Cart extends Controller return $this->renderError($this->model->getError() ?: '加入购物车失败'); } // 购物车商品总数量 - $totalNum = $this->model->getGoodsNum(); + $totalNum = $this->model->getTotalNum(); return $this->renderSuccess(['cart_total_num' => $totalNum], '加入购物车成功'); } diff --git a/source/application/api/controller/Goods.php b/source/application/api/controller/Goods.php index 8804b7c..9c7683f 100644 --- a/source/application/api/controller/Goods.php +++ b/source/application/api/controller/Goods.php @@ -48,15 +48,11 @@ class Goods extends Controller if ($goods === false) { return $this->renderError($model->getError() ?: '商品信息不存在'); } - // 多规格商品sku信息, todo: 已废弃 v1.1.25 - $specData = $goods['spec_type'] == 20 ? $model->getManySpecData($goods['spec_rel'], $goods['sku']) : null; return $this->renderSuccess([ // 商品详情 'detail' => $goods, // 购物车商品总数量 - 'cart_total_num' => $user ? (new CartModel($user))->getGoodsNum() : 0, - // 多规格商品sku信息 - 'specData' => $specData, + 'cart_total_num' => $user ? (new CartModel($user))->getTotalNum() : 0, ]); } diff --git a/source/application/api/controller/sharp/Goods.php b/source/application/api/controller/sharp/Goods.php index 3fdfcf5..dd6deca 100644 --- a/source/application/api/controller/sharp/Goods.php +++ b/source/application/api/controller/sharp/Goods.php @@ -37,7 +37,7 @@ class Goods extends Controller { // 获取秒杀活动商品详情 $service = new ActiveService; - $data = $service->getyActiveGoodsDetail($active_time_id, $sharp_goods_id); + $data = $service->getActiveGoodsDetail($active_time_id, $sharp_goods_id); if ($data === false) { return $this->renderError($service->getError()); } @@ -56,7 +56,7 @@ class Goods extends Controller { // 获取秒杀活动商品详情 $service = new ActiveService; - $data = $service->getyActiveGoodsDetail($active_time_id, $sharp_goods_id); + $data = $service->getActiveGoodsDetail($active_time_id, $sharp_goods_id); if ($data === false) { return $this->renderError($service->getError()); } diff --git a/source/application/api/model/UserCoupon.php b/source/application/api/model/UserCoupon.php index a4185a3..d644e60 100644 --- a/source/application/api/model/UserCoupon.php +++ b/source/application/api/model/UserCoupon.php @@ -12,22 +12,29 @@ use app\common\model\UserCoupon as UserCouponModel; */ class UserCoupon extends UserCouponModel { + /** * 获取用户优惠券列表 - * @param $user_id - * @param bool $is_use 是否已使用 - * @param bool $is_expire 是否已过期 + * @param $userId + * @param bool $isUse 是否已使用 + * @param bool $isExpire 是否已过期 + * @param float $amount 订单消费金额 * @return false|\PDOStatement|string|\think\Collection * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ - public function getList($user_id, $is_use = false, $is_expire = false) + public function getList($userId, $isUse = false, $isExpire = false, $amount = null) { - return $this->where('user_id', '=', $user_id) - ->where('is_use', '=', $is_use ? 1 : 0) - ->where('is_expire', '=', $is_expire ? 1 : 0) - ->select(); + // 构建查询对象 + $query = $this->where('user_id', '=', $userId) + ->where('is_use', '=', $isUse) + ->where('is_expire', '=', $isExpire); + // 最低消费金额 + if (!is_null($amount) && $amount > 0) { + $query->where('min_price', '<=', $amount); + } + return $query->select(); } /** @@ -103,6 +110,7 @@ class UserCoupon extends UserCouponModel 'start_time' => $start_time, 'end_time' => $end_time, 'apply_range' => $coupon['apply_range'], + 'apply_range_config' => $coupon['apply_range_config'], 'user_id' => $user['user_id'], 'wxapp_id' => self::$wxapp_id ]; @@ -144,22 +152,21 @@ class UserCoupon extends UserCouponModel /** * 订单结算优惠券列表 - * @param int $user_id 用户id + * @param int $userId 用户id * @param double $orderPayPrice 订单商品总金额 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ - public static function getUserCouponList($user_id, $orderPayPrice) + public static function getUserCouponList($userId, $orderPayPrice) { - // todo: 新增筛选条件: 最低消费金额 // 获取用户可用的优惠券列表 - $list = (new self)->getList($user_id); + $list = (new static)->getList($userId, false, false, $orderPayPrice); $data = []; foreach ($list as $coupon) { // 最低消费金额 - if ($orderPayPrice < $coupon['min_price']) continue; + // if ($orderPayPrice < $coupon['min_price']) continue; // 有效期范围内 if ($coupon['start_time']['value'] > time()) continue; $key = $coupon['user_coupon_id']; @@ -174,10 +181,11 @@ class UserCoupon extends UserCouponModel 'expire_type' => $coupon['expire_type'], 'start_time' => $coupon['start_time'], 'end_time' => $coupon['end_time'], + 'apply_range' => $coupon['apply_range'], + 'apply_range_config' => $coupon['apply_range_config'] ]; // 计算打折金额 if ($coupon['coupon_type']['value'] == 20) { -// $reduce_price = $orderPayPrice * ($coupon['discount'] / 10); $reducePrice = helper::bcmul($orderPayPrice, $coupon['discount'] / 10); $data[$key]['reduced_price'] = bcsub($orderPayPrice, $reducePrice, 2); } else @@ -187,4 +195,32 @@ class UserCoupon extends UserCouponModel return array_sort($data, 'reduced_price', true); } + /** + * 判断当前优惠券是否满足订单使用条件 + * @param $couponList + * @param $orderGoodsIds + * @return mixed + */ + public static function couponListApplyRange($couponList, $orderGoodsIds) + { + // 名词解释(is_apply):允许用于抵扣当前订单 + foreach ($couponList as &$item) { + if ($item['apply_range'] == 10) { + // 1. 全部商品 + $item['is_apply'] = true; + } elseif ($item['apply_range'] == 20) { + // 2. 指定商品, 判断订单商品是否存在可用 + $applyGoodsIds = array_intersect($item['apply_range_config']['applyGoodsIds'], $orderGoodsIds); + $item['is_apply'] = !empty($applyGoodsIds); + } elseif ($item['apply_range'] == 30) { + // 2. 排除商品, 判断订单商品是否全部都在排除行列 + $excludedGoodsIds = array_intersect($item['apply_range_config']['excludedGoodsIds'], $orderGoodsIds); + $item['is_apply'] = count($excludedGoodsIds) != count($orderGoodsIds); + } + !$item['is_apply'] && $item['not_apply_info'] = '该优惠券不支持当前商品'; + + } + return $couponList; + } + } diff --git a/source/application/api/service/order/Checkout.php b/source/application/api/service/order/Checkout.php index 3bd5ae8..076e4e3 100644 --- a/source/application/api/service/order/Checkout.php +++ b/source/application/api/service/order/Checkout.php @@ -367,7 +367,13 @@ class Checkout if (!$this->checkoutRule['is_coupon']) { return []; } - return UserCouponModel::getUserCouponList($this->user['user_id'], $orderTotalPrice); + // 整理当前订单所有商品ID集 + $orderGoodsIds = helper::getArrayColumn($this->goodsList, 'goods_id'); + // 当前用户可用的优惠券列表 + $couponList = UserCouponModel::getUserCouponList($this->user['user_id'], $orderTotalPrice); + // 判断当前优惠券是否满足订单使用条件 ( 优惠券适用范围 ) + $couponList = UserCouponModel::couponListApplyRange($couponList, $orderGoodsIds); + return $couponList; } /** @@ -529,19 +535,12 @@ class Checkout helper::setDataAttribute($this->goodsList, [ 'coupon_money' => 0, // 优惠券抵扣金额 ], true); - // 是否开启优惠券折扣 - if (!$this->checkoutRule['is_coupon']) { + // 验证选择的优惠券ID是否合法 + if (!$this->verifyOrderCouponId($couponId, $couponList)) { return false; } - // 如果没有可用的优惠券,直接返回 - if ($couponId <= 0 || empty($couponList)) { - return true; - } // 获取优惠券信息 - $couponInfo = helper::getArrayItemByColumn($couponList, 'user_coupon_id', $couponId); - if ($couponInfo == false) { - throw new BaseException(['msg' => '未找到优惠券信息']); - } + $couponInfo = $this->getCouponInfo($couponId, $couponList); // 计算订单商品优惠券抵扣金额 $goodsListTemp = helper::getArrayColumns($this->goodsList, ['total_price']); $CouponMoney = new GoodsDeductService; @@ -556,6 +555,40 @@ class Checkout return true; } + /** + * 验证用户选择的优惠券ID是否合法 + * @param $couponId + * @param $couponList + * @return bool + * @throws BaseException + */ + private function verifyOrderCouponId($couponId, $couponList) + { + // 是否开启优惠券折扣 + if (!$this->checkoutRule['is_coupon']) { + return false; + } + // 如果没有可用的优惠券,直接返回 + if ($couponId <= 0 || empty($couponList)) { + return false; + } + // 判断优惠券是否存在 + $couponInfo = $this->getCouponInfo($couponId, $couponList); + if (!$couponInfo) { + throw new BaseException(['msg' => '未找到优惠券信息']); + } + // 判断优惠券适用范围是否合法 + if (!$couponInfo['is_apply']) { + throw new BaseException(['msg' => $couponInfo['not_apply_info']]); + } + return true; + } + + private function getCouponInfo($couponId, $couponList) + { + return helper::getArrayItemByColumn($couponList, 'user_coupon_id', $couponId); + } + /** * 订单配送-快递配送 * @return bool diff --git a/source/application/api/service/sharp/Active.php b/source/application/api/service/sharp/Active.php index 2210bbe..8d929a7 100644 --- a/source/application/api/service/sharp/Active.php +++ b/source/application/api/service/sharp/Active.php @@ -88,7 +88,7 @@ class Active extends Basics * @return array|bool * @throws \think\exception\DbException */ - public function getyActiveGoodsDetail($activeTimeId, $sharpGoodsId) + public function getActiveGoodsDetail($activeTimeId, $sharpGoodsId) { // 活动详情 $active = $this->getGoodsActive($activeTimeId, $sharpGoodsId); @@ -160,7 +160,7 @@ class Active extends Basics $startTime = $model['active']['active_date'] + ($model->active_time->getData('active_time') * 60 * 60); $endTime = $startTime + (1 * 60 * 60); $activeStatus = $this->getActivcGoodsStatus($startTime, $endTime); - $data = [ + return [ 'active_id' => $model['active_id'], 'active_time_id' => $model['active_time_id'], 'active_time' => $model['active_time']['active_time'], @@ -171,7 +171,6 @@ class Active extends Basics 'count_down_time' => $this->getGoodsActiveCountDownTime($activeStatus, $startTime, $endTime), 'wxapp_id' => $model['wxapp_id'], ]; - return $data; } /** diff --git a/source/application/common/library/wechat/WxPay.php b/source/application/common/library/wechat/WxPay.php index 66c1836..f879fb8 100644 --- a/source/application/common/library/wechat/WxPay.php +++ b/source/application/common/library/wechat/WxPay.php @@ -191,6 +191,12 @@ class WxPay extends WxBase } // 格式化返回结果 $prepay = $this->fromXml($result); + // 记录日志 + log_write(['describe' => '微信退款API', [ + 'params' => $params, + 'result' => $result, + 'prepay' => $prepay + ]]); // 请求失败 if ($prepay['return_code'] === 'FAIL') { throw new BaseException(['msg' => 'return_msg: ' . $prepay['return_msg']]); diff --git a/source/application/common/model/Coupon.php b/source/application/common/model/Coupon.php index c63bc26..0da2417 100644 --- a/source/application/common/model/Coupon.php +++ b/source/application/common/model/Coupon.php @@ -21,6 +21,15 @@ class Coupon extends BaseModel 'state' ]; + /** + * 默认数据: 适用范围配置 + * @var array[] + */ + protected $applyRangeConfig = [ + 'applyGoodsIds' => [], + 'excludedGoodsIds' => [] + ]; + /** * 优惠券状态 (是否可领取) * @param $value @@ -93,6 +102,27 @@ class Coupon extends BaseModel return ['text' => date('Y/m/d', $value), 'value' => $value]; } + /** + * 获取器:适用范围配置 + * @param $value + * @return mixed + */ + public function getApplyRangeConfigAttr($value) + { + $array = $value ? helper::jsonDecode($value) : []; + return array_merge($this->applyRangeConfig, $array); + } + + /** + * 修改器:适用范围配置 + * @param $array + * @return mixed + */ + public function setApplyRangeConfigAttr($array) + { + return helper::jsonEncode(array_merge($this->applyRangeConfig, $array)); + } + /** * 修改器:折扣率 * @param $value diff --git a/source/application/common/model/UserCoupon.php b/source/application/common/model/UserCoupon.php index be22b35..1c2a5c2 100644 --- a/source/application/common/model/UserCoupon.php +++ b/source/application/common/model/UserCoupon.php @@ -3,6 +3,7 @@ namespace app\common\model; use think\Hook; +use app\common\library\helper; /** * 用户优惠券模型 @@ -108,6 +109,26 @@ class UserCoupon extends BaseModel return ['text' => date('Y/m/d', $value), 'value' => $value]; } + /** + * 获取器:适用范围配置 + * @param $value + * @return mixed + */ + public function getApplyRangeConfigAttr($value) + { + return $value ? helper::jsonDecode($value) : []; + } + + /** + * 修改器:适用范围配置 + * @param $array + * @return mixed + */ + public function setApplyRangeConfigAttr($array) + { + return helper::jsonEncode($array); + } + /** * 优惠券详情 * @param $coupon_id diff --git a/source/application/store/controller/apps/dealer/Withdraw.php b/source/application/store/controller/apps/dealer/Withdraw.php index ff5964d..724fa77 100644 --- a/source/application/store/controller/apps/dealer/Withdraw.php +++ b/source/application/store/controller/apps/dealer/Withdraw.php @@ -54,9 +54,7 @@ class Withdraw extends Controller { // 提现记录详情 $model = WithdrawModel::detail($id); - // 验证已冻结佣金是否合法 - // 合法 -> 确认打款 - if (!$model->verifyUserFreezeMoney($model['user_id'], $model['money']) && $model->money()) { + if ($model->money()) { return $this->renderSuccess('操作成功'); } return $this->renderError($model->getError() ?: '操作失败'); @@ -73,6 +71,11 @@ class Withdraw extends Controller public function wechat_pay($id) { $model = WithdrawModel::detail($id); + // 验证已冻结佣金是否合法 + if (!$model->verifyUserFreezeMoney($model['user_id'], $model['money'])) { + return $this->renderError($model->getError()); + } + // 合法 -> 确认打款 if ($model->wechatPay()) { return $this->renderSuccess('操作成功'); } diff --git a/source/application/store/controller/market/Basic.php b/source/application/store/controller/market/Basic.php index 82c5dd6..ebdea6b 100644 --- a/source/application/store/controller/market/Basic.php +++ b/source/application/store/controller/market/Basic.php @@ -3,7 +3,7 @@ namespace app\store\controller\market; use app\store\controller\Controller; -use app\store\model\Goods; +use app\store\model\Goods as GoodsModel; use app\store\model\Region as RegionModel; use app\store\model\Setting as SettingModel; @@ -22,10 +22,16 @@ class Basic extends Controller public function full_free() { if (!$this->request->isAjax()) { + // 满额包邮设置 $values = SettingModel::getItem('full_free'); return $this->fetch('full_free', [ - 'goodsList' => (new Goods)->getListByIds($values['notin_goods']), - 'regionData' => RegionModel::getCacheTree(), // 所有地区 + // 不参与包邮的商品列表 + 'goodsList' => (new GoodsModel)->getListByIds($values['notin_goods']), + // 获取所有地区(树状结构) + 'regionData' => RegionModel::getCacheTree(), + // 地区总数 + 'cityCount' => RegionModel::getCacheCounts()['city'], + // 满额包邮设置 'values' => $values ]); } @@ -36,4 +42,4 @@ class Basic extends Controller return $this->renderError($model->getError() ?: '操作失败'); } -} \ No newline at end of file +} diff --git a/source/application/store/controller/market/Coupon.php b/source/application/store/controller/market/Coupon.php index bd3ac1c..20c9ce8 100644 --- a/source/application/store/controller/market/Coupon.php +++ b/source/application/store/controller/market/Coupon.php @@ -3,6 +3,7 @@ namespace app\store\controller\market; use app\store\controller\Controller; +use app\store\model\Goods as GoodsModel; use app\store\model\Coupon as CouponModel; use app\store\model\UserCoupon as UserCouponModel; @@ -67,7 +68,14 @@ class Coupon extends Controller // 优惠券详情 $model = CouponModel::detail($coupon_id); if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); + // 适用范围商品列表 + $goodsModel = new GoodsModel; + // 指定的商品列表 + $applyGoodsList = $goodsModel->getListByIds($model['apply_range_config']['applyGoodsIds']); + // 指定的商品列表 + $excludedGoodsList = $goodsModel->getListByIds($model['apply_range_config']['excludedGoodsIds']); + // 加载模板输出 + return $this->fetch('edit', compact('model', 'applyGoodsList', 'excludedGoodsList')); } // 更新记录 if ($model->edit($this->postData('coupon'))) { diff --git a/source/application/store/model/DeliveryRule.php b/source/application/store/model/DeliveryRule.php index 2fa7e42..cb2ba71 100644 --- a/source/application/store/model/DeliveryRule.php +++ b/source/application/store/model/DeliveryRule.php @@ -11,45 +11,5 @@ use app\common\model\DeliveryRule as DeliveryRuleModel; */ class DeliveryRule extends DeliveryRuleModel { - protected $append = ['region_content']; - - static $regionAll; - static $regionTree; - - /** - * 可配送区域 - * @param $value - * @param $data - * @return string - */ - public function getRegionContentAttr($value, $data) - { - // 当前区域记录转换为数组 - $regionIds = explode(',', $data['region']); - - if (count($regionIds) === 373) return '全国'; - - // 所有地区 - if (empty(self::$regionAll)) { - self::$regionAll = Region::getCacheAll(); - self::$regionTree = Region::getCacheTree(); - } - // 将当前可配送区域格式化为树状结构 - $alreadyTree = []; - foreach ($regionIds as $regionId) - $alreadyTree[self::$regionAll[$regionId]['pid']][] = $regionId; - $str = ''; - foreach ($alreadyTree as $provinceId => $citys) { - $str .= self::$regionTree[$provinceId]['name']; - if (count($citys) !== count(self::$regionTree[$provinceId]['city'])) { - $cityStr = ''; - foreach ($citys as $cityId) - $cityStr .= self::$regionTree[$provinceId]['city'][$cityId]['name']; - $str .= ' (' . mb_substr($cityStr, 0, -1, 'utf-8') . ')'; - } - $str .= '、'; - } - return mb_substr($str, 0, -1, 'utf-8'); - } } diff --git a/source/application/store/view/market/basic/full_free.php b/source/application/store/view/market/basic/full_free.php index cb0a357..5cd8fa5 100644 --- a/source/application/store/view/market/basic/full_free.php +++ b/source/application/store/view/market/basic/full_free.php @@ -63,7 +63,7 @@
- 全国 + 全国