From 8e72121a32d819d9cc71dedbeb41be8d9cf43f63 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Thu, 21 Mar 2024 16:19:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=A1=A5=E8=B4=B4=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/store/coupon/StoreCouponDetail.php | 6 +++++ app/common/model/user/User.php | 5 ++++ .../admin/system/financial/Subsidy.php | 26 +++++++++++++++++-- app/controller/api/server/StoreOrder.php | 1 - app/controller/api/store/order/StoreOrder.php | 6 ++--- crmeb/listens/OrderDeliveryListen.php | 5 ++++ 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/app/common/model/store/coupon/StoreCouponDetail.php b/app/common/model/store/coupon/StoreCouponDetail.php index 93db60e4..bf177fb2 100644 --- a/app/common/model/store/coupon/StoreCouponDetail.php +++ b/app/common/model/store/coupon/StoreCouponDetail.php @@ -3,6 +3,7 @@ namespace app\common\model\store\coupon; use app\common\model\BaseModel; +use app\common\model\user\User; /** * Class StoreCouponDetail @@ -61,6 +62,11 @@ class StoreCouponDetail extends BaseModel return $this->hasOne(StoreCouponUser::class, 'coupon_user_id', 'coupon_user_id'); } + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } + /** * 使用优惠券 * @param $order diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index e207142f..5977c063 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -387,4 +387,9 @@ class User extends BaseModel return Merchant::where('uid', $this->uid)->value('mer_id'); } + public function merchant() + { + return $this->hasOne(Merchant::class, 'uid', 'uid'); + } + } diff --git a/app/controller/admin/system/financial/Subsidy.php b/app/controller/admin/system/financial/Subsidy.php index 20c2dd46..ecf76507 100644 --- a/app/controller/admin/system/financial/Subsidy.php +++ b/app/controller/admin/system/financial/Subsidy.php @@ -2,9 +2,12 @@ namespace app\controller\admin\system\financial; +use app\common\model\store\coupon\StoreCoupon; use app\common\model\store\coupon\StoreCouponDetail; +use app\common\repositories\store\coupon\StoreCouponRepository; use crmeb\basic\BaseController; use think\App; +use think\db\Query; class Subsidy extends BaseController { @@ -17,10 +20,29 @@ class Subsidy extends BaseController public function index() { [$page, $limit] = $this->getPage(); - $query = StoreCouponDetail::where('status', StoreCouponDetail::STATUS_INVALID) + $type = $this->request->get('type', ''); + $status = $this->request->get('status', ''); + $query = StoreCouponDetail::with(['user' => function (Query $query) { + $query->with(['merchant' => function (Query $query) { + $query->field('mer_id,uid,mer_name'); + }])->field('uid,nickname,avatar'); + }]) + ->where('status', StoreCouponDetail::STATUS_INVALID) ->where('type', StoreCouponDetail::TYPE_INCOME); + if (!empty($type)) { + if ($type == 1) { + $couponWhere = ['type' => StoreCouponRepository::TYPE_STORE_COUPON]; + } else { + $couponWhere = ['type' => StoreCouponRepository::TYPE_SALE_SUBSIDY]; + } + $couponId = StoreCoupon::where($couponWhere)->value('coupon_id'); + $query->where('coupon_id', $couponId); + } + if ($status !== '') { + $query->where('send_status', $status); + } $count = $query->count(); - $list = $query->page($page, $limit)->order('id desc')->select()->toArray(); + $list = $query->page($page, $limit)->order('send_status asc')->order('id desc')->select()->toArray(); $append = ['field' => 'send_status', 'value' => 'send_status_name', 'relation' => StoreCouponDetail::SEND_STATUS_MAP]; $list = append_to_array($list, $append); return app('json')->success(['count' => $count, 'list'=> $list]); diff --git a/app/controller/api/server/StoreOrder.php b/app/controller/api/server/StoreOrder.php index e4e5ef41..b44fec5b 100644 --- a/app/controller/api/server/StoreOrder.php +++ b/app/controller/api/server/StoreOrder.php @@ -194,7 +194,6 @@ class StoreOrder extends BaseController break; default: //快递 $data = $this->request->params([ - 'delivery_type', 'delivery_type', 'delivery_name', 'delivery_id', diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index cd45f9f5..7befb691 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -358,13 +358,13 @@ class StoreOrder extends BaseController { $user = $this->request->userInfo(); if (empty($user['withdrawal_pwd'])) { - return app('json')->fail(['msg' => '请设置支付密码', 'code'=> 101]); + return app('json')->success(['msg' => '请设置支付密码', 'code'=> 101]); } $transPwd = $this->request->post('withdrawal_pwd'); if (!password_verify((string)$transPwd, $user['withdrawal_pwd'])) { - return app('json')->fail(['msg' => '支付密码错误', 'code'=> 102]); + return app('json')->success(['msg' => '支付密码错误', 'code'=> 102]); } - return app('json')->success('验证通过'); + return app('json')->success(['msg' => '验证通过', 'code'=> 100]); } } diff --git a/crmeb/listens/OrderDeliveryListen.php b/crmeb/listens/OrderDeliveryListen.php index 9d44c9a7..9801933f 100644 --- a/crmeb/listens/OrderDeliveryListen.php +++ b/crmeb/listens/OrderDeliveryListen.php @@ -57,6 +57,11 @@ class OrderDeliveryListen implements ListenerInterface $userCouponRepo->onlyDetail = true; $userCouponRepo->detailStatus = StoreCouponDetail::STATUS_INVALID; $userCouponRepo->sendStatus = StoreCouponDetail::SEND_REPEAL; + $userCouponRepo->extra = [ + 'sale_target' => $couponTotal, + 'purchase_target' => $couponTotal * 0.4, + 'official_purchase_target' => $couponTotal * 0.6, + ]; $userCouponRepo->send(); } }