|
|
@@ -12,15 +12,39 @@ namespace app\common\repositories\store\order;
|
|
12
|
12
|
|
|
13
|
13
|
|
|
14
|
14
|
use app\common\dao\store\order\StoreGroupOrderDao;
|
|
|
15
|
+use app\common\enum\CommonEnum;
|
|
|
16
|
+use app\common\enum\store\CartEnum;
|
|
|
17
|
+use app\common\enum\store\ProductEnum;
|
|
|
18
|
+use app\common\enum\store\StoreGroupOrderEnum;
|
|
|
19
|
+use app\common\enum\store\StoreOrderEnum;
|
|
|
20
|
+use app\common\enum\store\StoreOrderStatusEnum;
|
|
15
|
21
|
use app\common\repositories\BaseRepository;
|
|
16
|
|
-use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
|
|
22
|
+use app\common\repositories\product\ProductSeckillRepository;
|
|
|
23
|
+use app\common\repositories\product\ShareRepository;
|
|
|
24
|
+use app\common\repositories\store\product\ProductAttrValueRepository;
|
|
|
25
|
+use app\common\repositories\store\product\ProductRepository;
|
|
|
26
|
+use app\common\repositories\store\StoreSeckillActiveRepository;
|
|
|
27
|
+use app\common\repositories\system\merchant\MerchantRepository;
|
|
|
28
|
+use app\common\repositories\user\UserAddressRepository;
|
|
|
29
|
+use app\common\repositories\user\UserRepository;
|
|
|
30
|
+use app\entity\data\merchant\MerchantEntity;
|
|
|
31
|
+use app\entity\data\product\ProductSeckillEntity;
|
|
|
32
|
+use app\entity\data\product\ShareEntity;
|
|
|
33
|
+use app\entity\data\store\CartEntity;
|
|
17
|
34
|
use app\entity\data\store\StoreGroupOrderEntity;
|
|
18
|
|
-use crmeb\jobs\CancelGroupOrderJob;
|
|
|
35
|
+use app\entity\data\store\StoreOrderEntity;
|
|
|
36
|
+use app\entity\data\store\StoreOrderProductEntity;
|
|
|
37
|
+use app\entity\data\store\StoreOrderStatusEntity;
|
|
|
38
|
+use app\entity\data\store\StoreProductAttrValueEntity;
|
|
|
39
|
+use app\entity\data\store\StoreProductEntity;
|
|
|
40
|
+use app\entity\data\user\UserAddressEntity;
|
|
|
41
|
+use app\entity\data\user\UserEntity;
|
|
|
42
|
+use app\entity\monomer\store\FzonePayTypeEntity;
|
|
|
43
|
+use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
|
|
19
|
44
|
use think\db\exception\DbException;
|
|
20
|
45
|
use think\exception\ValidateException;
|
|
21
|
|
-use think\facade\Cache;
|
|
22
|
46
|
use think\facade\Db;
|
|
23
|
|
-use think\facade\Queue;
|
|
|
47
|
+use think\facade\Log;
|
|
24
|
48
|
use think\model\Relation;
|
|
25
|
49
|
|
|
26
|
50
|
/**
|
|
|
@@ -54,7 +78,7 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
54
|
78
|
*/
|
|
55
|
79
|
public function getList(array $where, $page, $limit)
|
|
56
|
80
|
{
|
|
57
|
|
- $query = $this->search($where)->where('test_order',0);
|
|
|
81
|
+ $query = $this->search($where)->where('test_order', 0);
|
|
58
|
82
|
$count = $query->count();
|
|
59
|
83
|
$list = $query->with(['orderList' => function (Relation $query) {
|
|
60
|
84
|
$query->field('order_id,group_order_id')->with('orderProduct');
|
|
|
@@ -76,14 +100,15 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
76
|
100
|
*/
|
|
77
|
101
|
public function detail($uid, $id)
|
|
78
|
102
|
{
|
|
79
|
|
- $data = $this->search(['paid' => 0, 'uid' => $uid])->where('group_order_id', $id)->with(['orderList' => function (Relation $query) {
|
|
|
103
|
+ $data = $this->search(['paid' => 0, 'uid' => $uid])->where('group_order_id', $id)->with(['orderList' => function (Relation $query) {
|
|
80
|
104
|
$query->field('order_id,group_order_id,mer_id,order_sn,pay_price,mark,coupon_price,total_price,total_postage')->with(['merchant' => function ($query) {
|
|
81
|
105
|
$query->field('mer_id,mer_name,mer_avatar');
|
|
82
|
106
|
}, 'orderProduct']);
|
|
83
|
107
|
}])->find();
|
|
84
|
|
- $data['pay_end_time'] = strtotime($data['create_time']) + 60*15;
|
|
85
|
|
- return $data;
|
|
|
108
|
+ $data['pay_end_time'] = strtotime($data['create_time']) + 60 * 15;
|
|
|
109
|
+ return $data;
|
|
86
|
110
|
}
|
|
|
111
|
+
|
|
87
|
112
|
/**
|
|
88
|
113
|
* @param $uid
|
|
89
|
114
|
* @param $id
|
|
|
@@ -96,13 +121,13 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
96
|
121
|
*/
|
|
97
|
122
|
public function detail_noUid($id)
|
|
98
|
123
|
{
|
|
99
|
|
- $data = $this->search(['paid' => 0])->where('group_order_id', $id)->with(['orderList' => function (Relation $query) {
|
|
|
124
|
+ $data = $this->search(['paid' => 0])->where('group_order_id', $id)->with(['orderList' => function (Relation $query) {
|
|
100
|
125
|
$query->field('order_id,group_order_id,mer_id,order_sn,pay_price,mark,coupon_price,total_price,total_postage')->with(['merchant' => function ($query) {
|
|
101
|
126
|
$query->field('mer_id,mer_name,mer_avatar');
|
|
102
|
127
|
}, 'orderProduct']);
|
|
103
|
128
|
}])->find();
|
|
104
|
|
- if($data){
|
|
105
|
|
- $data['pay_end_time'] = strtotime($data['create_time']) + 60*15;
|
|
|
129
|
+ if ($data) {
|
|
|
130
|
+ $data['pay_end_time'] = strtotime($data['create_time']) + 60 * 15;
|
|
106
|
131
|
}
|
|
107
|
132
|
return $data;
|
|
108
|
133
|
}
|
|
|
@@ -127,105 +152,136 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
127
|
152
|
}
|
|
128
|
153
|
|
|
129
|
154
|
/**
|
|
130
|
|
- * @param $id
|
|
131
|
|
- * @param null $uid
|
|
132
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
133
|
|
- * @throws DbException
|
|
134
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
135
|
|
- * @author xaboy
|
|
136
|
|
- * @day 2020/6/10
|
|
|
155
|
+ * @param int $groupOrderId
|
|
|
156
|
+ * @param int|null $uid
|
|
|
157
|
+ * @param string $changeMessage
|
|
|
158
|
+ * @param string $remark
|
|
|
159
|
+ * @return void
|
|
137
|
160
|
*/
|
|
138
|
|
- public function cancel($id, $uid = null, $change_message = '', $remark = '')
|
|
|
161
|
+ public function cancel(int $groupOrderId, int $uid = null, string $changeMessage = '', string $remark = '')
|
|
139
|
162
|
{
|
|
140
|
|
- $groupOrder = $this->search(['paid' => 0, 'uid' => $uid ?: ''])->where('group_order_id', $id)->with(['orderList'])->find();
|
|
141
|
|
- if (!$groupOrder)
|
|
|
163
|
+ // 1、验证要操作的订单组是否状态合法
|
|
|
164
|
+ $storeGroupOrderEntity = $this->getStoreGroupOrderEntityByGroupOrderId($groupOrderId);
|
|
|
165
|
+ if (empty($storeGroupOrderEntity->getGroupOrderId())) {
|
|
142
|
166
|
throw new ValidateException('订单不存在');
|
|
143
|
|
- if ($groupOrder['paid'] != 0)
|
|
144
|
|
- throw new ValidateException('订单状态错误,无法删除');
|
|
145
|
|
- //TODO 关闭订单
|
|
146
|
|
- Db::transaction(function () use ($remark, $groupOrder, $id, $uid,$change_message) {
|
|
147
|
|
- $redis = Cache::store('redis')->handler();
|
|
148
|
|
-
|
|
149
|
|
- $groupOrder->is_del = 1;
|
|
150
|
|
- $orderStatus = [];
|
|
151
|
|
- foreach ($groupOrder->orderList as $order) {
|
|
152
|
|
-// $order->is_del = 1;
|
|
153
|
|
- $order->status = 6;
|
|
154
|
|
-// $order->is_settlement = -1;
|
|
155
|
|
- $order->save();
|
|
156
|
|
- $orderStatus[] = [
|
|
157
|
|
- 'order_id' => $order->order_id,
|
|
158
|
|
- 'change_type' => 'cancel',
|
|
159
|
|
- 'change_message' => $uid === 0 ? ('取消原因:'.$change_message . "[商家操作]\n 商家备注:" . ($remark ?: '')) : ($change_message ? $change_message : '取消订单' . ($uid ? '' : '[自动]'))
|
|
160
|
|
- ];
|
|
161
|
|
- // 取消订单时 删除限制合伙人商品代理限制
|
|
162
|
|
- $key ='area_manage_order:'.$order['area_manage_address_ids'];
|
|
163
|
|
- $redis->del($key);
|
|
164
|
|
- }
|
|
165
|
|
- $groupOrder->save();
|
|
166
|
|
-
|
|
167
|
|
- //取消订单,返还京豆和积分
|
|
168
|
|
- $orderId = $order->order_id;
|
|
169
|
|
- $userSignScoreInfo = Db::name('user_sign_score')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
|
|
170
|
|
- if($userSignScoreInfo){
|
|
171
|
|
- $userDecScore = $userSignScoreInfo['reward_socre'];
|
|
172
|
|
- Db::name('user_sign_score')
|
|
173
|
|
- ->where('id', $userSignScoreInfo['id'])
|
|
174
|
|
- ->update([
|
|
175
|
|
- 'status' => 0,
|
|
176
|
|
- ]);
|
|
177
|
|
-
|
|
178
|
|
- //返还扣除积分
|
|
179
|
|
- $user = Db::name('user')->where('uid', $uid)->find();
|
|
180
|
|
- $userScore = $user['score'];
|
|
181
|
|
- $ins_data['uid'] = $uid;
|
|
182
|
|
- $ins_data['reward_socre'] = $userDecScore;
|
|
183
|
|
- $ins_data['addtime'] = time();
|
|
184
|
|
- $ins_data['status'] = 1;//京豆状态1-有效 0-失效 -1待确认 创建的时候-1待确认 取消订单返还积分变为0 支付成功变为1
|
|
185
|
|
- $ins_data['order_type'] = 'cancel_order';
|
|
186
|
|
- $ins_data['order_id'] = $orderId;
|
|
187
|
|
- $ins_data['mark'] = "取消订单返还预扣积分";
|
|
188
|
|
- $ins_data['desc'] = '取消订单返还预扣积分';
|
|
189
|
|
- $ins_data['surplus'] = $userScore + $userDecScore;
|
|
190
|
|
- $ins_data['type'] = 4;//没用
|
|
191
|
|
- $ins_data['pm'] = 1;
|
|
192
|
|
- Db::name('user_sign_score')->insertGetId($ins_data);
|
|
193
|
|
- Db::name('user')->where('uid', $uid)->inc('score', $userDecScore)->update();
|
|
194
|
|
- }
|
|
|
167
|
+ }
|
|
|
168
|
+ if ($storeGroupOrderEntity->getPaid() != StoreGroupOrderEnum::PAID['NO']['code']) {
|
|
|
169
|
+ throw new ValidateException('订单状态错误');
|
|
|
170
|
+ }
|
|
195
|
171
|
|
|
196
|
|
- $userSignJingdouInfo = Db::name('user_sign_jingdou')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
|
|
197
|
|
- if($userSignJingdouInfo){
|
|
198
|
|
- $userDecJingScore = $userSignJingdouInfo['number'];
|
|
199
|
|
- Db::name('user_sign_jingdou')
|
|
200
|
|
- ->where('id',$userSignJingdouInfo['id'])
|
|
201
|
|
- ->update([
|
|
202
|
|
- 'status' => 0,
|
|
203
|
|
- ]);
|
|
204
|
|
-
|
|
205
|
|
- //返还扣除京豆
|
|
206
|
|
- $user = Db::name('user')->where('uid', $uid)->find();
|
|
207
|
|
- $userJingdou = $user['jingdou'];
|
|
208
|
|
- $ins_data['uid'] = $uid;
|
|
209
|
|
- $ins_data['number'] = $userDecJingScore;
|
|
210
|
|
- $ins_data['status'] = 1;
|
|
211
|
|
- $ins_data['mark'] = "取消订单返还预扣京豆";
|
|
212
|
|
- $ins_data['desc'] = "取消订单返还预扣京豆";
|
|
213
|
|
- $ins_data['order_id'] = $orderId;
|
|
214
|
|
- $ins_data['surplus'] = $userJingdou + $userDecJingScore;
|
|
215
|
|
- $ins_data['order_type'] = 'cancel_order';
|
|
216
|
|
- $ins_data['type'] = 1;
|
|
217
|
|
- $ins_data['addtime'] = time();
|
|
218
|
|
- Db::name('user_sign_jingdou')
|
|
219
|
|
- ->insertGetId($ins_data);
|
|
220
|
|
- Db::name('user')->where('uid', $uid)->inc('jingdou', $userDecJingScore)->update();
|
|
221
|
|
- }
|
|
|
172
|
+ // 2、验证订单信息
|
|
|
173
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
174
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
175
|
+ $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByGroupOrderId($storeGroupOrderEntity->getGroupOrderId());
|
|
|
176
|
+ if (empty($storeOrderEntityList)) {
|
|
|
177
|
+ throw new ValidateException('订单信息错误');
|
|
|
178
|
+ }
|
|
222
|
179
|
|
|
|
180
|
+ // 3、逻辑处理
|
|
|
181
|
+ (new \think\facade\Db)->startTrans();
|
|
|
182
|
+ try {
|
|
|
183
|
+ // 软 删除订单组
|
|
|
184
|
+ $storeGroupOrderEntity->setIsDel(StoreGroupOrderEnum::IS_DEL['Yes']['code']);
|
|
|
185
|
+ $this->update($storeGroupOrderEntity->getGroupOrderId(), $storeGroupOrderEntity->toUnderlineArray());
|
|
223
|
186
|
|
|
|
187
|
+ // 循环关闭订单组内的数据
|
|
|
188
|
+ foreach ($storeOrderEntityList as $storeOrderEntity) {
|
|
|
189
|
+ $storeOrderRepository->closeStoreOrder($storeOrderEntity, $uid, $changeMessage, $remark);
|
|
|
190
|
+ }
|
|
224
|
191
|
|
|
225
|
|
- app()->make(StoreOrderStatusRepository::class)->insertAll($orderStatus);
|
|
|
192
|
+ (new \think\facade\Db)->commit();
|
|
|
193
|
+ } catch (DbException $e) {
|
|
|
194
|
+ (new \think\facade\Db)->rollback();
|
|
|
195
|
+ }
|
|
226
|
196
|
|
|
227
|
|
- });
|
|
228
|
|
- Queue::push(CancelGroupOrderJob::class, $id);
|
|
|
197
|
+ // $groupOrder = $this->search(['paid' => 0, 'uid' => $uid ?: ''])->where('group_order_id', $id)->with(['orderList'])->find();
|
|
|
198
|
+ // if (!$groupOrder)
|
|
|
199
|
+ // throw new ValidateException('订单不存在');
|
|
|
200
|
+ // if ($groupOrder['paid'] != 0)
|
|
|
201
|
+ // throw new ValidateException('订单状态错误,无法删除');
|
|
|
202
|
+ // Db::transaction(function () use ($remark, $groupOrder, $id, $uid,$change_message) {
|
|
|
203
|
+ // $redis = Cache::store('redis')->handler();
|
|
|
204
|
+ //
|
|
|
205
|
+ // $groupOrder->is_del = 1;
|
|
|
206
|
+ // $orderStatus = [];
|
|
|
207
|
+ // foreach ($groupOrder->orderList as $order) {
|
|
|
208
|
+ // // $order->is_del = 1;
|
|
|
209
|
+ // $order->status = 6;
|
|
|
210
|
+ // // $order->is_settlement = -1;
|
|
|
211
|
+ // $order->save();
|
|
|
212
|
+ // $orderStatus[] = [
|
|
|
213
|
+ // 'order_id' => $order->order_id,
|
|
|
214
|
+ // 'change_type' => 'cancel',
|
|
|
215
|
+ // 'change_message' => $uid === 0 ? ('取消原因:'.$change_message . "[商家操作]\n 商家备注:" . ($remark ?: '')) : ($change_message ? $change_message : '取消订单' . ($uid ? '' : '[自动]'))
|
|
|
216
|
+ // ];
|
|
|
217
|
+ // // 取消订单时 删除限制合伙人商品代理限制
|
|
|
218
|
+ // $key ='area_manage_order:'.$order['area_manage_address_ids'];
|
|
|
219
|
+ // $redis->del($key);
|
|
|
220
|
+ // }
|
|
|
221
|
+ // $groupOrder->save();
|
|
|
222
|
+ //
|
|
|
223
|
+ // //取消订单,返还京豆和积分
|
|
|
224
|
+ // $orderId = $order->order_id;
|
|
|
225
|
+ // $userSignScoreInfo = Db::name('user_sign_score')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
|
|
|
226
|
+ // if($userSignScoreInfo){
|
|
|
227
|
+ // $userDecScore = $userSignScoreInfo['reward_socre'];
|
|
|
228
|
+ // Db::name('user_sign_score')
|
|
|
229
|
+ // ->where('id', $userSignScoreInfo['id'])
|
|
|
230
|
+ // ->update([
|
|
|
231
|
+ // 'status' => 0,
|
|
|
232
|
+ // ]);
|
|
|
233
|
+ //
|
|
|
234
|
+ // //返还扣除积分
|
|
|
235
|
+ // $user = Db::name('user')->where('uid', $uid)->find();
|
|
|
236
|
+ // $userScore = $user['score'];
|
|
|
237
|
+ // $ins_data['uid'] = $uid;
|
|
|
238
|
+ // $ins_data['reward_socre'] = $userDecScore;
|
|
|
239
|
+ // $ins_data['addtime'] = time();
|
|
|
240
|
+ // $ins_data['status'] = 1;//京豆状态1-有效 0-失效 -1待确认 创建的时候-1待确认 取消订单返还积分变为0 支付成功变为1
|
|
|
241
|
+ // $ins_data['order_type'] = 'cancel_order';
|
|
|
242
|
+ // $ins_data['order_id'] = $orderId;
|
|
|
243
|
+ // $ins_data['mark'] = "取消订单返还预扣积分";
|
|
|
244
|
+ // $ins_data['desc'] = '取消订单返还预扣积分';
|
|
|
245
|
+ // $ins_data['surplus'] = $userScore + $userDecScore;
|
|
|
246
|
+ // $ins_data['type'] = 4;//没用
|
|
|
247
|
+ // $ins_data['pm'] = 1;
|
|
|
248
|
+ // Db::name('user_sign_score')->insertGetId($ins_data);
|
|
|
249
|
+ // Db::name('user')->where('uid', $uid)->inc('score', $userDecScore)->update();
|
|
|
250
|
+ // }
|
|
|
251
|
+ //
|
|
|
252
|
+ // $userSignJingdouInfo = Db::name('user_sign_jingdou')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
|
|
|
253
|
+ // if($userSignJingdouInfo){
|
|
|
254
|
+ // $userDecJingScore = $userSignJingdouInfo['number'];
|
|
|
255
|
+ // Db::name('user_sign_jingdou')
|
|
|
256
|
+ // ->where('id',$userSignJingdouInfo['id'])
|
|
|
257
|
+ // ->update([
|
|
|
258
|
+ // 'status' => 0,
|
|
|
259
|
+ // ]);
|
|
|
260
|
+ //
|
|
|
261
|
+ // //返还扣除京豆
|
|
|
262
|
+ // $user = Db::name('user')->where('uid', $uid)->find();
|
|
|
263
|
+ // $userJingdou = $user['jingdou'];
|
|
|
264
|
+ // $ins_data['uid'] = $uid;
|
|
|
265
|
+ // $ins_data['number'] = $userDecJingScore;
|
|
|
266
|
+ // $ins_data['status'] = 1;
|
|
|
267
|
+ // $ins_data['mark'] = "取消订单返还预扣京豆";
|
|
|
268
|
+ // $ins_data['desc'] = "取消订单返还预扣京豆";
|
|
|
269
|
+ // $ins_data['order_id'] = $orderId;
|
|
|
270
|
+ // $ins_data['surplus'] = $userJingdou + $userDecJingScore;
|
|
|
271
|
+ // $ins_data['order_type'] = 'cancel_order';
|
|
|
272
|
+ // $ins_data['type'] = 1;
|
|
|
273
|
+ // $ins_data['addtime'] = time();
|
|
|
274
|
+ // Db::name('user_sign_jingdou')
|
|
|
275
|
+ // ->insertGetId($ins_data);
|
|
|
276
|
+ // Db::name('user')->where('uid', $uid)->inc('jingdou', $userDecJingScore)->update();
|
|
|
277
|
+ // }
|
|
|
278
|
+ //
|
|
|
279
|
+ //
|
|
|
280
|
+ //
|
|
|
281
|
+ // app()->make(StoreOrderStatusRepository::class)->insertAll($orderStatus);
|
|
|
282
|
+ //
|
|
|
283
|
+ // });
|
|
|
284
|
+ // Queue::push(CancelGroupOrderJob::class, $id);
|
|
229
|
285
|
}
|
|
230
|
286
|
|
|
231
|
287
|
/**
|
|
|
@@ -235,19 +291,20 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
235
|
291
|
* @throws DbException
|
|
236
|
292
|
* @throws \think\db\exception\ModelNotFoundException
|
|
237
|
293
|
*/
|
|
238
|
|
- public function ProductOutCancel($product_id){
|
|
|
294
|
+ public function ProductOutCancel($product_id)
|
|
|
295
|
+ {
|
|
239
|
296
|
$order = Db::name('store_order')
|
|
240
|
|
- -> alias('so')
|
|
241
|
|
- -> join('store_group_order sgo','so.group_order_id= sgo.group_order_id')
|
|
242
|
|
- -> join('store_order_product sop','sop.order_id= so.order_id')
|
|
243
|
|
- -> where('so.paid',0)
|
|
244
|
|
- -> where('so.is_del', 0)
|
|
245
|
|
- -> where('so.status', 5)
|
|
246
|
|
- -> where('sop.product_id',$product_id)
|
|
247
|
|
-// -> where('so.create_time','<','2022-06-26')
|
|
248
|
|
- -> field('so.group_order_id,so.order_id,so.status')
|
|
249
|
|
- -> select();
|
|
250
|
|
- foreach ($order as $v){
|
|
|
297
|
+ ->alias('so')
|
|
|
298
|
+ ->join('store_group_order sgo', 'so.group_order_id= sgo.group_order_id')
|
|
|
299
|
+ ->join('store_order_product sop', 'sop.order_id= so.order_id')
|
|
|
300
|
+ ->where('so.paid', 0)
|
|
|
301
|
+ ->where('so.is_del', 0)
|
|
|
302
|
+ ->where('so.status', 5)
|
|
|
303
|
+ ->where('sop.product_id', $product_id)
|
|
|
304
|
+ // -> where('so.create_time','<','2022-06-26')
|
|
|
305
|
+ ->field('so.group_order_id,so.order_id,so.status')
|
|
|
306
|
+ ->select();
|
|
|
307
|
+ foreach ($order as $v) {
|
|
251
|
308
|
$this->cancel($v['group_order_id']);
|
|
252
|
309
|
}
|
|
253
|
310
|
return $order;
|
|
|
@@ -278,6 +335,31 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
278
|
335
|
return $this->dao->getStoreGroupOrderEntityListByGroupOrderIdList($groupOrderIdList);
|
|
279
|
336
|
}
|
|
280
|
337
|
|
|
|
338
|
+ /**
|
|
|
339
|
+ * @param string $groupOrderSn
|
|
|
340
|
+ * @return StoreGroupOrderEntity
|
|
|
341
|
+ */
|
|
|
342
|
+ public function getStoreGroupOrderEntityByGroupOrderSn(string $groupOrderSn): StoreGroupOrderEntity
|
|
|
343
|
+ {
|
|
|
344
|
+ $entityList = $this->getStoreGroupOrderEntityListByGroupOrderSnList([$groupOrderSn]);
|
|
|
345
|
+ $entity = array_shift($entityList);
|
|
|
346
|
+ if ($entity instanceof StoreGroupOrderEntity) {
|
|
|
347
|
+ return $entity;
|
|
|
348
|
+ } else {
|
|
|
349
|
+ /** @var StoreGroupOrderEntity */
|
|
|
350
|
+ return StoreGroupOrderEntity::newInstance();
|
|
|
351
|
+ }
|
|
|
352
|
+ }
|
|
|
353
|
+
|
|
|
354
|
+ /**
|
|
|
355
|
+ * @param array $groupOrderSnList
|
|
|
356
|
+ * @return StoreGroupOrderEntity[]
|
|
|
357
|
+ */
|
|
|
358
|
+ public function getStoreGroupOrderEntityListByGroupOrderSnList(array $groupOrderSnList): array
|
|
|
359
|
+ {
|
|
|
360
|
+ return $this->dao->getStoreGroupOrderEntityListByGroupOrderSnList($groupOrderSnList);
|
|
|
361
|
+ }
|
|
|
362
|
+
|
|
281
|
363
|
public function create($data)
|
|
282
|
364
|
{
|
|
283
|
365
|
return $this->dao->create($data);
|
|
|
@@ -297,12 +379,591 @@ class StoreGroupOrderRepository extends BaseRepository
|
|
297
|
379
|
}
|
|
298
|
380
|
|
|
299
|
381
|
/**
|
|
300
|
|
- * @param $groupOrderId
|
|
|
382
|
+ * @return string
|
|
|
383
|
+ * @author xaboy
|
|
|
384
|
+ * @day 2020/6/9
|
|
|
385
|
+ */
|
|
|
386
|
+ public function getNewOrderId(): string
|
|
|
387
|
+ {
|
|
|
388
|
+ list($msec, $sec) = explode(' ', microtime());
|
|
|
389
|
+ $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
|
|
|
390
|
+ $orderId = 'wx' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
|
|
|
391
|
+ return $orderId;
|
|
|
392
|
+ }
|
|
|
393
|
+
|
|
|
394
|
+ /**
|
|
|
395
|
+ * 验证订单 信息是否 合规
|
|
|
396
|
+ * @param StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity
|
|
|
397
|
+ * @return array
|
|
|
398
|
+ */
|
|
|
399
|
+ public function verifyRequestInformation(StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity): array
|
|
|
400
|
+ {
|
|
|
401
|
+ // 3、验证
|
|
|
402
|
+ /** 验证 用户信息 */
|
|
|
403
|
+ /** @var UserRepository $userRepository */
|
|
|
404
|
+ $userRepository = app()->make(UserRepository::class);
|
|
|
405
|
+ $userEntity = $userRepository->getUserEntityByUid($storeOrderCreateRequestEntity->getUid());
|
|
|
406
|
+ if (empty($userEntity->getUid())) {
|
|
|
407
|
+ throw new ValidateException('获取当前用户信息失败');
|
|
|
408
|
+ }
|
|
|
409
|
+
|
|
|
410
|
+ /** 验证 收货地址 */
|
|
|
411
|
+ /** @var UserAddressRepository $userAddressRepository */
|
|
|
412
|
+ $userAddressRepository = app()->make(UserAddressRepository::class);
|
|
|
413
|
+ $addressEntity = $userAddressRepository->getAddressEntityByAddressId($storeOrderCreateRequestEntity->getAddressId());
|
|
|
414
|
+ if (empty($addressEntity->getAddressId()) || $addressEntity->getUid() != $storeOrderCreateRequestEntity->getUid()) {
|
|
|
415
|
+ throw new ValidateException('请选择正确的收货地址');
|
|
|
416
|
+ }
|
|
|
417
|
+ if (empty($addressEntity->getCodeList())) {
|
|
|
418
|
+ throw new ValidateException('地址需要选择4级地址!请修改地址!');
|
|
|
419
|
+ }
|
|
|
420
|
+
|
|
|
421
|
+ /** 验证分享信息 分享 */
|
|
|
422
|
+ /** @var ShareEntity $shareEntity */
|
|
|
423
|
+ $shareEntity = ShareEntity::newInstance();
|
|
|
424
|
+ if (!empty($storeOrderCreateRequestEntity->getShareId())) {
|
|
|
425
|
+ /** @var ShareRepository $shareRepository */
|
|
|
426
|
+ $shareRepository = app()->make(ShareRepository::class);
|
|
|
427
|
+ $shareEntity = $shareRepository->getShareEntityByShareId($storeOrderCreateRequestEntity->getShareId());
|
|
|
428
|
+ if (empty($shareEntity->getId())) {
|
|
|
429
|
+ throw new ValidateException('无效的分享信息');
|
|
|
430
|
+ }
|
|
|
431
|
+ }
|
|
|
432
|
+
|
|
|
433
|
+ /** 验证 购物车信息 */
|
|
|
434
|
+ // 目前购物车只能添加一件商品,据了解之前 写的购物车,添加多件商品组合支付时计算的 金额和 VR 积分之类的会有问题
|
|
|
435
|
+ /** @var StoreCartRepository $storeCartRepository */
|
|
|
436
|
+ $storeCartRepository = app()->make(StoreCartRepository::class);
|
|
|
437
|
+ $cartEntityList = $storeCartRepository->getCartEntityListByCartIdList($storeOrderCreateRequestEntity->getCartIdList());
|
|
|
438
|
+ if (empty($cartEntityList) || count($storeOrderCreateRequestEntity->getCartIdList()) != count($cartEntityList)) {
|
|
|
439
|
+ throw new ValidateException('未查询到购物车信息');
|
|
|
440
|
+ }
|
|
|
441
|
+
|
|
|
442
|
+ $merchantIdList = [];
|
|
|
443
|
+ $productIdList = [];
|
|
|
444
|
+ $productAttrUniqueList = [];
|
|
|
445
|
+ foreach ($cartEntityList as $cartEntity) {
|
|
|
446
|
+ if (empty($cartEntity->getMerId())) {
|
|
|
447
|
+ throw new ValidateException('商户不存在');
|
|
|
448
|
+ }
|
|
|
449
|
+ if (empty($cartEntity->getProductId())) {
|
|
|
450
|
+ throw new ValidateException('商品已下架');
|
|
|
451
|
+ }
|
|
|
452
|
+ if (empty($cartEntity->getProductAttrUnique())) {
|
|
|
453
|
+ throw new ValidateException('商品已下架');
|
|
|
454
|
+ }
|
|
|
455
|
+ $merchantIdList[] = $cartEntity->getMerId();
|
|
|
456
|
+ $productIdList[] = $cartEntity->getProductId();
|
|
|
457
|
+ $productAttrUniqueList[] = $cartEntity->getProductAttrUnique();
|
|
|
458
|
+ }
|
|
|
459
|
+ $merchantIdList = array_unique($merchantIdList);
|
|
|
460
|
+ $productIdList = array_unique($productIdList);
|
|
|
461
|
+ $productAttrUniqueList = array_unique($productAttrUniqueList);
|
|
|
462
|
+
|
|
|
463
|
+
|
|
|
464
|
+ // 商户
|
|
|
465
|
+ /** @var MerchantRepository $merchantRepository */
|
|
|
466
|
+ $merchantRepository = app()->make(MerchantRepository::class);
|
|
|
467
|
+ $merchantEntityList = $merchantRepository->getMerchantEntityListByMerchantIdList($merchantIdList);
|
|
|
468
|
+ if (count($merchantIdList) != count($merchantEntityList)) {
|
|
|
469
|
+ throw new ValidateException('未查询到商户信息');
|
|
|
470
|
+ }
|
|
|
471
|
+ // 商户信息 MAP
|
|
|
472
|
+ /** @var MerchantEntity[] $merchantEntityMap 商户信息 MAP */
|
|
|
473
|
+ $merchantEntityMap = array_column($merchantEntityList, null, 'merId');
|
|
|
474
|
+
|
|
|
475
|
+ // 商品
|
|
|
476
|
+ /** @var ProductRepository $storeProductRepository */
|
|
|
477
|
+ $storeProductRepository = app()->make(ProductRepository::class);
|
|
|
478
|
+ $storeProductEntityList = $storeProductRepository->getStoreProductEntityListByProductIdList($productIdList);
|
|
|
479
|
+ if (count($productIdList) != count($storeProductEntityList)) {
|
|
|
480
|
+ throw new ValidateException('未查询到商品信息');
|
|
|
481
|
+ }
|
|
|
482
|
+ // 商品信息 MAP
|
|
|
483
|
+ /** @var StoreProductEntity[] $storeProductEntityMap */
|
|
|
484
|
+ $storeProductEntityMap = array_column($storeProductEntityList, null, 'productId');
|
|
|
485
|
+
|
|
|
486
|
+ // 商品属性
|
|
|
487
|
+ /** @var ProductAttrValueRepository $storeProductAttrValueRepository */
|
|
|
488
|
+ $storeProductAttrValueRepository = app()->make(ProductAttrValueRepository::class);
|
|
|
489
|
+ $storeProductAttrValueEntityList = $storeProductAttrValueRepository->getStoreProductAttrValueEntityListByUniqueList($productAttrUniqueList);
|
|
|
490
|
+ if (count($productAttrUniqueList) != count($storeProductAttrValueEntityList)) {
|
|
|
491
|
+ throw new ValidateException('未查询到商品属性信息');
|
|
|
492
|
+ }
|
|
|
493
|
+ // 商品属性信息 MAP
|
|
|
494
|
+ /** @var StoreProductAttrValueEntity[] $storeProductAttrValueEntityMap */
|
|
|
495
|
+ $storeProductAttrValueEntityMap = array_column($storeProductAttrValueEntityList, null, 'unique');
|
|
|
496
|
+
|
|
|
497
|
+ // 订单表
|
|
|
498
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
499
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
500
|
+
|
|
|
501
|
+ // 确认购物车内 微唯宝 的商品 是否满足发货
|
|
|
502
|
+ foreach ($cartEntityList as $cartEntity) {
|
|
|
503
|
+ // 验证用户
|
|
|
504
|
+ if ($cartEntity->getUid() != $userEntity->getUid()) {
|
|
|
505
|
+ throw new ValidateException('获取购物车内容失败');
|
|
|
506
|
+ }
|
|
|
507
|
+
|
|
|
508
|
+ // 验证商户
|
|
|
509
|
+ if (empty($merchantEntityMap[$cartEntity->getMerId()])) {
|
|
|
510
|
+ throw new ValidateException('未查询到商户信息');
|
|
|
511
|
+ }
|
|
|
512
|
+
|
|
|
513
|
+ // 获取购物车商品信息
|
|
|
514
|
+ if (empty($storeProductEntityMap[$cartEntity->getProductId()])) {
|
|
|
515
|
+ throw new ValidateException('未查询到商品信息');
|
|
|
516
|
+ }
|
|
|
517
|
+ $productEntity = $storeProductEntityMap[$cartEntity->getProductId()];
|
|
|
518
|
+
|
|
|
519
|
+ if ($productEntity->getMerId() != $cartEntity->getMerId()) {
|
|
|
520
|
+ throw new ValidateException('商家已下架该产品');
|
|
|
521
|
+ }
|
|
|
522
|
+
|
|
|
523
|
+ if (empty($storeProductAttrValueEntityMap[$cartEntity->getProductAttrUnique()])) {
|
|
|
524
|
+ throw new ValidateException('未查询到商品属性信息');
|
|
|
525
|
+ }
|
|
|
526
|
+ $productAttrValueEntity = $storeProductAttrValueEntityMap[$cartEntity->getProductAttrUnique()];
|
|
|
527
|
+
|
|
|
528
|
+ // 判断订单是否已失效
|
|
|
529
|
+ if ($cartEntity->getIsFail() == CartEnum::IS_FAIL['Yes']['code']) {
|
|
|
530
|
+ throw new ValidateException($productEntity->getStoreName() . ' 已失效');
|
|
|
531
|
+ }
|
|
|
532
|
+ // 判断订单是否已失效
|
|
|
533
|
+ if ($cartEntity->getIsPay() == CartEnum::IS_PAY['Yes']['code']) {
|
|
|
534
|
+ throw new ValidateException($productEntity->getStoreName() . ' 已下单');
|
|
|
535
|
+ }
|
|
|
536
|
+
|
|
|
537
|
+ // 如果商品类型是 普通商品 ,则判断库存是否充足
|
|
|
538
|
+ if ($cartEntity->getProductType() == CartEnum::PRODUCT_TYPE['Ordinary']['code']) {
|
|
|
539
|
+ if ($productAttrValueEntity->getStock() < $cartEntity->getCartNum()) {
|
|
|
540
|
+ throw new ValidateException($productEntity->getStoreName() . ' 库存不足--' . $cartEntity->getCartNum());
|
|
|
541
|
+ }
|
|
|
542
|
+ } else {
|
|
|
543
|
+ // 如果是秒杀商品 应该首先判断是否还在活动期间内(rrx_store_seckill_active 商户设置秒杀商品关联表)
|
|
|
544
|
+ // 商户设置秒杀商品关联表
|
|
|
545
|
+ /** @var StoreSeckillActiveRepository $storeSeckillActiveRepository */
|
|
|
546
|
+ $storeSeckillActiveRepository = app()->make(StoreSeckillActiveRepository::class);
|
|
|
547
|
+ $seckillActiveEntity = $storeSeckillActiveRepository->getSeckillActiveEntityByProductIdInActive($cartEntity->getProductId());
|
|
|
548
|
+ if (empty($seckillActiveEntity->getSeckillActiveId())) {
|
|
|
549
|
+ throw new ValidateException($productEntity->getStoreName() . ' 秒杀活动已失效');
|
|
|
550
|
+ }
|
|
|
551
|
+
|
|
|
552
|
+ // 如果不是普通商品 则是否秒杀产品,如果是秒杀产品则判断是否超卖
|
|
|
553
|
+ if (!$storeOrderRepository->getDayPayCount($cartEntity->getUid(), $cartEntity->getProductId()) || !$storeOrderRepository->getPayCount($cartEntity->getUid(), $cartEntity->getProductId())) {
|
|
|
554
|
+ throw new ValidateException($productEntity->getStoreName() . ' 已超出购买限制');
|
|
|
555
|
+ }
|
|
|
556
|
+ }
|
|
|
557
|
+
|
|
|
558
|
+ // 检查库存 查看 此商品已下架 此商品规格无货 此商品不支持该地区
|
|
|
559
|
+ // (按照代码中所写的逻辑来推理:从微唯宝拉取过来,从而上架到商品表的商品,都有SPUId,所以去走微唯宝提供的接口验证,而会员专区和商贸区的商品可能是商户自己加的,没有SPUId,所以也就不用走微唯宝的验证)
|
|
|
560
|
+ $checkGong = $storeProductAttrValueRepository->checkGong($cartEntity->getProductId(), $cartEntity->getProductAttrUnique(), $cartEntity->getCartNum(), $storeOrderCreateRequestEntity->getUid(), $storeOrderCreateRequestEntity->getAddressId());
|
|
|
561
|
+ if (isset($checkGong['code']) && $checkGong['code'] == -1) {
|
|
|
562
|
+ throw new ValidateException($checkGong['message']);
|
|
|
563
|
+ }
|
|
|
564
|
+ }
|
|
|
565
|
+
|
|
|
566
|
+ return [
|
|
|
567
|
+ 'userEntity' => $userEntity,
|
|
|
568
|
+ 'cartEntityList' => $cartEntityList,
|
|
|
569
|
+ 'addressEntity' => $addressEntity,
|
|
|
570
|
+ 'shareEntity' => $shareEntity,
|
|
|
571
|
+ 'merchantEntityMap' => $merchantEntityMap,
|
|
|
572
|
+ 'storeProductEntityMap' => $storeProductEntityMap,
|
|
|
573
|
+ 'storeProductAttrValueEntityMap' => $storeProductAttrValueEntityMap,
|
|
|
574
|
+ ];
|
|
|
575
|
+ }
|
|
|
576
|
+
|
|
|
577
|
+ /**
|
|
|
578
|
+ * @param StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity
|
|
|
579
|
+ * @return array
|
|
|
580
|
+ */
|
|
|
581
|
+ public function createStoreGroupOrder(StoreOrderCreateRequestEntity $storeOrderCreateRequestEntity): array
|
|
|
582
|
+ {
|
|
|
583
|
+
|
|
|
584
|
+ // 1、验证数据合规性 并获取 请求 数据
|
|
|
585
|
+ $verifyResult = $this->verifyRequestInformation($storeOrderCreateRequestEntity);
|
|
|
586
|
+ /** @var UserEntity $userEntity 当前操作用户 */
|
|
|
587
|
+ $userEntity = $verifyResult['userEntity'];
|
|
|
588
|
+ /** @var CartEntity[] $cartEntityList 发起创建订单的购物车列表 */
|
|
|
589
|
+ $cartEntityList = $verifyResult['cartEntityList'];
|
|
|
590
|
+ /** @var CartEntity[] $cartEntityMap 发起创建订单的购物车映射 */
|
|
|
591
|
+ $cartEntityMap = array_column($cartEntityList, null, 'cartId');
|
|
|
592
|
+ $cartIdList = array_keys($cartEntityMap);
|
|
|
593
|
+ /** @var UserAddressEntity $addressEntity 地址信息 */
|
|
|
594
|
+ $addressEntity = $verifyResult['addressEntity'];
|
|
|
595
|
+ /** @var ShareEntity $shareEntity 订单所带的分享信息 */
|
|
|
596
|
+ $shareEntity = $verifyResult['shareEntity'];
|
|
|
597
|
+ /** @var MerchantEntity[] $merchantEntityMap 订单所涉及的商户信息映射 */
|
|
|
598
|
+ $merchantEntityMap = $verifyResult['merchantEntityMap'];
|
|
|
599
|
+ /** @var StoreProductEntity[] $storeProductEntityMap 订单所涉及的 商品信息 映射 */
|
|
|
600
|
+ $storeProductEntityMap = $verifyResult['storeProductEntityMap'];
|
|
|
601
|
+ /** @var StoreProductAttrValueEntity[] $storeProductAttrValueEntityMap 订单所涉及的 商品属性信息 */
|
|
|
602
|
+ $storeProductAttrValueEntityMap = $verifyResult['storeProductAttrValueEntityMap'];
|
|
|
603
|
+
|
|
|
604
|
+ // 2、加载 需要调用的 模块
|
|
|
605
|
+ // 商品秒杀
|
|
|
606
|
+ /** @var ProductSeckillRepository $productSeckillRepository */
|
|
|
607
|
+ $productSeckillRepository = app()->make(ProductSeckillRepository::class);
|
|
|
608
|
+ // // 优惠券 列表(商户or平台)
|
|
|
609
|
+ // /** @var StoreCouponRepository $storeCouponRepository */
|
|
|
610
|
+ // $storeCouponRepository = app()->make(StoreCouponRepository::class);
|
|
|
611
|
+ // // 优惠券 商品 关联表
|
|
|
612
|
+ // /** @var StoreCouponProductRepository $storeCouponProductRepository */
|
|
|
613
|
+ // $storeCouponProductRepository = app()->make(StoreCouponProductRepository::class);
|
|
|
614
|
+ // // 用户的优惠券领取记录
|
|
|
615
|
+ // /** @var StoreCouponUserRepository $storeCouponUserRepository */
|
|
|
616
|
+ // $storeCouponUserRepository = app()->make(StoreCouponUserRepository::class);
|
|
|
617
|
+
|
|
|
618
|
+ // 商品
|
|
|
619
|
+ /** @var ProductRepository $productRepository */
|
|
|
620
|
+ $productRepository = app()->make(ProductRepository::class);
|
|
|
621
|
+ // 商品属性
|
|
|
622
|
+ /** @var ProductAttrValueRepository $productAttrValueRepository */
|
|
|
623
|
+ $productAttrValueRepository = app()->make(ProductAttrValueRepository::class);
|
|
|
624
|
+
|
|
|
625
|
+ // 购物车
|
|
|
626
|
+ /** @var StoreCartRepository $storeCartRepository */
|
|
|
627
|
+ $storeCartRepository = app()->make(StoreCartRepository::class);
|
|
|
628
|
+
|
|
|
629
|
+ // 订单组
|
|
|
630
|
+ /** @var StoreGroupOrderRepository $storeGroupOrderRepository */
|
|
|
631
|
+ $storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
|
|
|
632
|
+ // 订单组
|
|
|
633
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
634
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
635
|
+
|
|
|
636
|
+ // 3、创建 变量
|
|
|
637
|
+ $storeOrderEntityList = []; // 订单数据实体列表 主要用于写入数据,循环获取数据
|
|
|
638
|
+ $storeCouponUserEntityListByMerIdMap = []; // 订单优惠券 商户 映射
|
|
|
639
|
+ $totalPrice = 0.00; // 订单总价
|
|
|
640
|
+ $totalPostage = 0.00; // 订单总邮费
|
|
|
641
|
+ $totalNum = 0; // 订单总商品数量
|
|
|
642
|
+ $totalCost = 0.00; // 订单商品 总成本
|
|
|
643
|
+ $productStockList = []; // 商品 库存更新列表
|
|
|
644
|
+ $productAttrValueStockList = []; // 商品 属性 库存更新列表
|
|
|
645
|
+
|
|
|
646
|
+ // 4、组装数据 每条购物车信息 就是一条订单数据
|
|
|
647
|
+ // 循环购物车 对购物车内的商品 进行条件验证 以及根据不同的商品 计算邮费
|
|
|
648
|
+ foreach ($cartEntityMap as $cartId => $cartEntity) {
|
|
|
649
|
+ // 获取商品 实体
|
|
|
650
|
+ $productEntity = $storeProductEntityMap[$cartEntity->getProductId()];
|
|
|
651
|
+ // 获取商品属性 实体
|
|
|
652
|
+ $productAttrValueEntity = $storeProductAttrValueEntityMap[$cartEntity->getProductAttrUnique()];
|
|
|
653
|
+
|
|
|
654
|
+ // 验证是否是秒杀产品 如果是秒杀产品,并且设置了 大仓会员价 则将大仓会员价 设置为 商品价格
|
|
|
655
|
+ $productSeckillEntity = ProductSeckillEntity::newInstance();
|
|
|
656
|
+ if ($productEntity->getSeckill() == ProductEnum::SECKILL['Yes']['code'] && !is_null($productEntity->getDcPrice()) && $productEntity->getDcPrice() > 0.00) {
|
|
|
657
|
+ // 获取 在活动期间内的 秒杀活动记录
|
|
|
658
|
+ $productSeckillEntity = $productSeckillRepository->getProductSeckillEntityByProductId($cartEntity->getProductId());
|
|
|
659
|
+ if (!empty($productSeckillEntity->getId())) {
|
|
|
660
|
+ // 把 商品属性的 价格 改成 大仓会员价
|
|
|
661
|
+ $productAttrValueEntity->setPrice($productEntity->getDcPrice());
|
|
|
662
|
+ }
|
|
|
663
|
+ }
|
|
|
664
|
+
|
|
|
665
|
+ // 计算优惠券 ****************** 优惠券是此步骤(第一步需要考虑的问题,但是目前阶段暂不需要该功能 所以未完成 先注释)
|
|
|
666
|
+ $youhuiPrice = 0.00;
|
|
|
667
|
+ // // 商品券 优先于 店铺券
|
|
|
668
|
+ // // 商品券(平台优惠券)
|
|
|
669
|
+ // if (!isset($storeCouponUserEntityListByMerIdMap[0])) {
|
|
|
670
|
+ // $storeCouponUserEntityListByMerIdMap[0] = $storeCouponUserRepository->getValidStoreCouponUserEntityListByMerIdAndUid(0, $cartEntity->getUid());
|
|
|
671
|
+ // }
|
|
|
672
|
+ // // 店铺券(满减券)
|
|
|
673
|
+ // if (!isset($storeCouponUserEntityListByMerIdMap[$cartEntity->getMerId()])) {
|
|
|
674
|
+ // // 查询 当前用户 在当前 店铺的 优惠券
|
|
|
675
|
+ // $storeCouponUserEntityListByMerIdMap[$cartEntity->getMerId()] = $storeCouponUserRepository->getValidStoreCouponUserEntityListByMerIdAndUid($cartEntity->getMerId(), $cartEntity->getUid());
|
|
|
676
|
+ // }
|
|
|
677
|
+ //
|
|
|
678
|
+ // if (!empty($storeCouponUserEntityListByMerIdMap[0]) || !empty($storeCouponUserEntityListByMerIdMap[$cartEntity->getMerId()])) {
|
|
|
679
|
+ // foreach ([0, $cartEntity->getMerId()] as $merId) {
|
|
|
680
|
+ // foreach ($storeCouponUserEntityListByMerIdMap[$merId] as $storeCouponUserEntity) {
|
|
|
681
|
+ // // 如果不能明确当前优惠券的 获取方式 ,则忽略当前的优惠券的有效性
|
|
|
682
|
+ // if (empty($storeCouponUserEntity->getType())) {
|
|
|
683
|
+ // continue;
|
|
|
684
|
+ // }
|
|
|
685
|
+ // // 优惠卷关联商品 辅助表
|
|
|
686
|
+ // $storeCouponProductEntityList = $storeCouponProductRepository->getStoreCouponProductEntityListByCouponId($storeCouponUserEntity->getCouponId());
|
|
|
687
|
+ // if (!empty($storeCouponProductEntityList)) {
|
|
|
688
|
+ // // 商品券
|
|
|
689
|
+ // foreach ($storeCouponProductEntityList as $storeCouponProductEntity) {
|
|
|
690
|
+ // // 如果当前 优惠券 所关联的 商品 是否在当前购买的 该商家的 商品列表中,(没有则说明此条关联记录 无用) 并且当前 该商家内 该商品没有已使用的优惠券
|
|
|
691
|
+ // if (in_array($storeCouponProductEntity->getProductId(), array_keys($productPriceByMerIdMap[$merchantEntity->getMerId()])) && !isset($useCouponProduct[$storeCouponProductEntity->getProductId()][$cartEntity->getCartId()])) {
|
|
|
692
|
+ // // 如果 当前该商家 该商品 的价格 超过了 “最低消费多少金额可用优惠券” 的金额 则记录该优惠金额,并记录该优惠券ID 后续设置为已使用
|
|
|
693
|
+ // if (($productAttrValueEntity->getPrice()) >= $storeCouponUserEntity->getUseMinPrice()) {
|
|
|
694
|
+ // $couponPrice = bcadd($couponPrice, $storeCouponUserEntity->getCouponPrice(), 2);
|
|
|
695
|
+ // // 一个商家的 一种商品 只能使用一次优惠券
|
|
|
696
|
+ // $useCouponProduct[$storeCouponProductEntity->getProductId()][$cartEntity->getCartId()][] = $storeCouponUserEntity->getCouponUserId();
|
|
|
697
|
+ // break;
|
|
|
698
|
+ // }
|
|
|
699
|
+ // }
|
|
|
700
|
+ // }
|
|
|
701
|
+ // } else {
|
|
|
702
|
+ // // 店铺券(平台券-满减券)
|
|
|
703
|
+ //
|
|
|
704
|
+ // }
|
|
|
705
|
+ // }
|
|
|
706
|
+ // }
|
|
|
707
|
+ // }
|
|
|
708
|
+
|
|
|
709
|
+ // 计算 每笔订单的价格
|
|
|
710
|
+ $price = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getPrice(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
711
|
+
|
|
|
712
|
+ // 计算运费 获取该商品的运费模板 运费表
|
|
|
713
|
+ // 判断商品是否是 供应链(微唯宝)商品
|
|
|
714
|
+ // $postage = $storeOrderRepository->calculatePostage(
|
|
|
715
|
+ // $productEntity,
|
|
|
716
|
+ // $productAttrValueEntity,
|
|
|
717
|
+ // $cartEntity->getCartNum(),
|
|
|
718
|
+ // $addressEntity->getCityId()
|
|
|
719
|
+ // );
|
|
|
720
|
+ $postage = 0.00; // 默认全都包邮s
|
|
|
721
|
+
|
|
|
722
|
+ // 汇付手续费 (订单价格 + 邮费) * 汇付手续费比例
|
|
|
723
|
+ $commissionRate = bcmul(bcadd($price, $postage, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT), CommonEnum::HUIFU_COMMISSION_CHARGE, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
724
|
+ // 平台拿到的钱(商户分润) 商品数量 * 每个商品的单件让利
|
|
|
725
|
+ $serviceMoney = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getPlateMerProfit(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
726
|
+ // 商家获利部分(成本) 订单价格 - 平台拿到的钱
|
|
|
727
|
+ $cost = bcsub($price, $serviceMoney, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
728
|
+ // 商家 实际可以得到的钱 商家获利部分 + 邮费 - 订单手续费
|
|
|
729
|
+ $merMoney = bcsub(bcadd($cost, $postage, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT), $commissionRate, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
|
|
|
730
|
+
|
|
|
731
|
+ // 计算总 邮费
|
|
|
732
|
+ $totalPostage = bcadd($totalPostage, $postage, 2);
|
|
|
733
|
+ // 计算总价
|
|
|
734
|
+ $totalPrice = bcadd($totalPrice, $price, 2);
|
|
|
735
|
+ // 计算总数
|
|
|
736
|
+ $totalNum = bcadd($totalNum, $cartEntity->getCartNum(), 2);
|
|
|
737
|
+ // 计算总成本
|
|
|
738
|
+ $totalCost = bcadd($totalCost, $cost, 2);
|
|
|
739
|
+
|
|
|
740
|
+ // 更新库存
|
|
|
741
|
+ $productStockList[] = ['productId' => $productEntity->getProductId(), 'cartNum' => $cartEntity->getCartNum()];
|
|
|
742
|
+ $productAttrValueStockList[] = ['productId' => $productAttrValueEntity->getProductId(), 'unique' => $productAttrValueEntity->getUnique(), 'cartNum' => $cartEntity->getCartNum()];
|
|
|
743
|
+
|
|
|
744
|
+ // 创建订单
|
|
|
745
|
+ /** @var StoreOrderEntity $storeOrderEntity */
|
|
|
746
|
+ $storeOrderEntity = StoreOrderEntity::newInstance();
|
|
|
747
|
+ $storeOrderEntity
|
|
|
748
|
+ ->setCommissionRate($commissionRate)
|
|
|
749
|
+ ->setExtensionOne($productAttrValueEntity->getExtensionOne())
|
|
|
750
|
+ // 二级佣金 此字段已被用于分佣比例
|
|
|
751
|
+ ->setExtensionTwo($productAttrValueEntity->getExtensionTwo())
|
|
|
752
|
+ ->setOrderSn($storeOrderRepository->getNewOrderId())
|
|
|
753
|
+ ->setUid($cartEntity->getUid())
|
|
|
754
|
+ ->setRealName($addressEntity->getRealName())
|
|
|
755
|
+ ->setUserPhone($addressEntity->getPhone())
|
|
|
756
|
+ ->setUserAddress($addressEntity->getProvince() . $addressEntity->getCity() . $addressEntity->getDistrict() . $addressEntity->getDetail())
|
|
|
757
|
+ ->setCartId($cartEntity->getCartId())
|
|
|
758
|
+ ->setTotalNum($cartEntity->getCartNum())
|
|
|
759
|
+ ->setTotalPrice(bcadd($price, $postage, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT))
|
|
|
760
|
+ ->setTotalPostage($postage)
|
|
|
761
|
+ ->setPayPostage($postage)
|
|
|
762
|
+ ->setPayPrice($price)
|
|
|
763
|
+ ->setMerId($cartEntity->getMerId())
|
|
|
764
|
+ ->setCost($cost)
|
|
|
765
|
+ ->setMerMoney($merMoney)
|
|
|
766
|
+ ->setPayType($storeOrderCreateRequestEntity->getPayType())
|
|
|
767
|
+ ->setShareId($storeOrderCreateRequestEntity->getShareId())
|
|
|
768
|
+ ->setShareUid($shareEntity->getUid())
|
|
|
769
|
+ ->setServiceMoney($serviceMoney)
|
|
|
770
|
+ ->setTestOrder($userEntity->getTestUser())
|
|
|
771
|
+ ->setDacangId($productEntity->getDcId())
|
|
|
772
|
+ ->setDistributionMode(StoreOrderEnum::DISTRIBUTION_MODE['ExpressDelivery']['code'])
|
|
|
773
|
+ ->setAddressId($addressEntity->getAddressId())
|
|
|
774
|
+ ->setSeckill($productSeckillEntity->getId())
|
|
|
775
|
+ ->setYouhuiPrice($youhuiPrice)
|
|
|
776
|
+ ->setDouhuomall(empty($productEntity->getSpuId()) ? StoreOrderEnum::DOHUOMALL['PlatformOrder']['code'] : StoreOrderEnum::DOHUOMALL['SupplyChainOrder']['code'])
|
|
|
777
|
+ ->setDouhuomallStatus(empty($productEntity->getSpuId()) ? null : StoreOrderEnum::DOHUOMALL_STATUS['NotSubmittedToWeiweiBao']['code'])
|
|
|
778
|
+ ->setFzonePaytype($storeOrderCreateRequestEntity->getFzonePayType())
|
|
|
779
|
+ ->setConPri($serviceMoney);
|
|
|
780
|
+ $storeOrderEntityList[] = $storeOrderEntity;
|
|
|
781
|
+ }
|
|
|
782
|
+
|
|
|
783
|
+ /** @var StoreGroupOrderEntity $storeGroupOrderEntity */
|
|
|
784
|
+ $storeGroupOrderEntity = StoreGroupOrderEntity::newInstance();
|
|
|
785
|
+ $storeGroupOrderEntity
|
|
|
786
|
+ ->setUid($userEntity->getUid())
|
|
|
787
|
+ ->setGroupOrderSn($storeGroupOrderRepository->getNewOrderId())
|
|
|
788
|
+ ->setTotalPostage($totalPostage)
|
|
|
789
|
+ ->setTotalPrice(bcadd($totalPrice, $totalPostage, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT))
|
|
|
790
|
+ ->setTotalNum($totalNum)
|
|
|
791
|
+ ->setRealName($addressEntity->getRealName())
|
|
|
792
|
+ ->setUserPhone($addressEntity->getPhone())
|
|
|
793
|
+ ->setUserAddress($addressEntity->getProvince() . $addressEntity->getCity() . $addressEntity->getDistrict() . $addressEntity->getDetail())
|
|
|
794
|
+ ->setPayPrice($totalPrice)
|
|
|
795
|
+ ->setPayPostage($totalPostage)
|
|
|
796
|
+ ->setCost($totalCost)
|
|
|
797
|
+ ->setPayType($storeOrderCreateRequestEntity->getPayType())
|
|
|
798
|
+ ->setFzonePaytype($storeOrderCreateRequestEntity->getFzonePayType());
|
|
|
799
|
+
|
|
|
800
|
+ // 4、写入数据
|
|
|
801
|
+ (new \think\facade\Db)->startTrans();
|
|
|
802
|
+ try {
|
|
|
803
|
+ // 4.1 更细库存
|
|
|
804
|
+ foreach ($productStockList as $item) {
|
|
|
805
|
+ $productRepository->descStock($item['productId'], $item['cartNum']);
|
|
|
806
|
+ }
|
|
|
807
|
+ foreach ($productAttrValueStockList as $item) {
|
|
|
808
|
+ $productAttrValueRepository->descStock($item['productId'], $item['unique'], $item['cartNum']);
|
|
|
809
|
+ }
|
|
|
810
|
+
|
|
|
811
|
+ // 4.2 修改 购物车状态
|
|
|
812
|
+ $storeCartRepository->updateIsPayByCartIdList($cartIdList);
|
|
|
813
|
+
|
|
|
814
|
+ // 4.3 写入 组合订单 (支付订单)
|
|
|
815
|
+ $storeGroupOrderEntity = $storeGroupOrderRepository->createByEntity($storeGroupOrderEntity);
|
|
|
816
|
+
|
|
|
817
|
+ // 4.5 写入订单数据
|
|
|
818
|
+ $storeOrderStatusEntityList = [];
|
|
|
819
|
+ $storeOrderProductEntityList = [];
|
|
|
820
|
+ $paySuccess = true; // 是否已完成支付 并支付成功
|
|
|
821
|
+ foreach ($storeOrderEntityList as $key => $storeOrderEntity) {
|
|
|
822
|
+ // 将订单数据 写入数据库 并完善实体
|
|
|
823
|
+ $storeOrderEntity->setGroupOrderId($storeGroupOrderEntity->getGroupOrderId());
|
|
|
824
|
+ $storeOrderEntity = $storeOrderRepository->createByEntity($storeOrderEntity);
|
|
|
825
|
+
|
|
|
826
|
+ // 4.4 验证是否 可以进行支付 因为历史的 用户资金(佣金、养老金、积分、VR等)扣减所绑定的orderId都是订单ID
|
|
|
827
|
+ /** @var FzonePayTypeEntity $fzonePayTypeEntity */
|
|
|
828
|
+ $fzonePayTypeEntity = FzonePayTypeEntity::newInstance($storeOrderCreateRequestEntity->getFzonePayType());
|
|
|
829
|
+ // 当有一笔支付失败时,默认整个 订单组 没有 "完全" 支付成功
|
|
|
830
|
+ if (!$storeOrderRepository->abatement($userEntity, $storeOrderEntity, $fzonePayTypeEntity)) {
|
|
|
831
|
+ $paySuccess = false;
|
|
|
832
|
+ }
|
|
|
833
|
+
|
|
|
834
|
+ // 将每件商品设计到的优惠券要取消掉
|
|
|
835
|
+
|
|
|
836
|
+ // 准备订单的 状态数据
|
|
|
837
|
+ $storeOrderStatusEntityList[] = StoreOrderStatusEntity::newInstance()
|
|
|
838
|
+ ->setOrderId($storeOrderEntity->getOrderId())
|
|
|
839
|
+ ->setChangeType(StoreOrderStatusEnum::CHANGE_TYPE['Create']['code'])
|
|
|
840
|
+ ->setChangeMessage(StoreOrderStatusEnum::CHANGE_TYPE['Create']['name']);
|
|
|
841
|
+
|
|
|
842
|
+ // 获取当前 订单绑定的购物车
|
|
|
843
|
+ $cartEntity = $cartEntityMap[$storeOrderEntity->getCartId()];
|
|
|
844
|
+ // 准备订单的 订单购物详情表
|
|
|
845
|
+ $storeOrderProductEntityList[] = StoreOrderProductEntity::newInstance()
|
|
|
846
|
+ ->setOrderId($storeOrderEntity->getOrderId())
|
|
|
847
|
+ ->setCartId($storeOrderEntity->getCartId())
|
|
|
848
|
+ ->setUid($storeOrderEntity->getUid())
|
|
|
849
|
+ ->setProductId($cartEntity->getProductId())
|
|
|
850
|
+ ->setProductPrice($storeOrderEntity->getTotalPrice())
|
|
|
851
|
+ ->setExtensionOne(0.00)
|
|
|
852
|
+ ->setExtensionTwo(0.00)
|
|
|
853
|
+ ->setProductSku($cartEntity->getProductAttrUnique())
|
|
|
854
|
+ ->setProductNum($cartEntity->getCartNum())
|
|
|
855
|
+ ->setRefundNum($cartEntity->getCartNum())
|
|
|
856
|
+ ->setType($storeProductEntityMap[$cartEntity->getProductId()]->getType())
|
|
|
857
|
+ ->setCartInfo(json_encode([
|
|
|
858
|
+ 'product' => $storeProductEntityMap[$cartEntity->getProductId()]->toUnderlineArray(),
|
|
|
859
|
+ 'productAttr' => $storeProductAttrValueEntityMap[$cartEntity->getProductAttrUnique()]->toUnderlineArray(),
|
|
|
860
|
+ 'product_type' => $cartEntity->getProductType()
|
|
|
861
|
+ ]));
|
|
|
862
|
+
|
|
|
863
|
+ }
|
|
|
864
|
+
|
|
|
865
|
+ // 4.6 订单操作记录表
|
|
|
866
|
+ /** @var StoreOrderStatusRepository $storeOrderStatusRepository */
|
|
|
867
|
+ $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
|
868
|
+ $storeOrderStatusRepository->createByEntityList($storeOrderStatusEntityList);
|
|
|
869
|
+
|
|
|
870
|
+ // 4.7 订单购物详情表
|
|
|
871
|
+ /** @var StoreOrderProductRepository $storeOrderProductRepository */
|
|
|
872
|
+ $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
|
|
|
873
|
+ $storeOrderProductRepository->createByEntityList($storeOrderProductEntityList);
|
|
|
874
|
+
|
|
|
875
|
+ // 4.8 支付成功后 发放奖励
|
|
|
876
|
+ // 非现金 支付成功后 直接结算
|
|
|
877
|
+ if ($paySuccess) {
|
|
|
878
|
+ $storeGroupOrderRepository->storeGroupOrderPaySuccess($storeGroupOrderEntity->getGroupOrderId());
|
|
|
879
|
+ }
|
|
|
880
|
+
|
|
|
881
|
+ (new \think\facade\Db)->commit();
|
|
|
882
|
+ } catch (DbException $e) {
|
|
|
883
|
+ (new \think\facade\Db)->rollback();
|
|
|
884
|
+ Log::error('StoreGroupOrderRepository-createStoreGroupOrder:' . $e->getMessage());
|
|
|
885
|
+ }
|
|
|
886
|
+ return ['order_id' => $storeGroupOrderEntity->getGroupOrderId(), 'groupOrder' => $storeGroupOrderEntity->toArray()];
|
|
|
887
|
+
|
|
|
888
|
+ }
|
|
|
889
|
+
|
|
|
890
|
+ /**
|
|
|
891
|
+ * @param int $groupOrderId
|
|
|
892
|
+ * @param string $rand 当现金支付时,汇付会在订单尾部跟一个随机数
|
|
|
893
|
+ * @param string|null $payOpenId 当现金支付时,付款人的Id
|
|
|
894
|
+ * @return void
|
|
|
895
|
+ * @throws DbException
|
|
|
896
|
+ */
|
|
|
897
|
+ public function storeGroupOrderPaySuccess(int $groupOrderId, string $rand = '', string $payOpenId = null): void
|
|
|
898
|
+ {
|
|
|
899
|
+ /** @var StoreGroupOrderRepository $storeGroupOrderRepository */
|
|
|
900
|
+ $storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
|
|
|
901
|
+ /** @var StoreOrderRepository $storeOrderRepository */
|
|
|
902
|
+ $storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
903
|
+
|
|
|
904
|
+ $storeGroupOrderEntity = $storeGroupOrderRepository->getStoreGroupOrderEntityByGroupOrderId($groupOrderId);
|
|
|
905
|
+ // 修改订单组的 支付状态
|
|
|
906
|
+ $storeGroupOrderRepository->paySuccessUpdateDB($storeGroupOrderEntity->getGroupOrderId(), $rand);
|
|
|
907
|
+
|
|
|
908
|
+ // 获取订单组 内的 所有订单
|
|
|
909
|
+ $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByGroupOrderId($storeGroupOrderEntity->getGroupOrderId());
|
|
|
910
|
+ $storeOrderIdList = array_column($storeOrderEntityList, 'orderId');
|
|
|
911
|
+ $storeCartIdList = array_column($storeOrderEntityList, 'cartId');
|
|
|
912
|
+
|
|
|
913
|
+ // 修改订单的 支付状态
|
|
|
914
|
+ $storeOrderRepository->paySuccessUpdateDB($storeOrderIdList, $payOpenId);
|
|
|
915
|
+
|
|
|
916
|
+ // 获取购物车信息
|
|
|
917
|
+ /** @var StoreCartRepository $storeCartRepository */
|
|
|
918
|
+ $storeCartRepository = app()->make(StoreCartRepository::class);
|
|
|
919
|
+ $cartEntityList = $storeCartRepository->getCartEntityListByCartIdList($storeCartIdList);
|
|
|
920
|
+ /** @var CartEntity[] $cartEntityMap 发起创建订单的购物车映射 */
|
|
|
921
|
+ $cartEntityMap = array_column($cartEntityList, null, 'cartId');
|
|
|
922
|
+
|
|
|
923
|
+ // 记录 需要立即计算的订单ID
|
|
|
924
|
+ $settlementOrderIdList = [];
|
|
|
925
|
+ $storeOrderStatusEntityList = [];
|
|
|
926
|
+ $financialRecordDataList = [];
|
|
|
927
|
+ foreach ($storeOrderEntityList as $storeOrderEntity) {
|
|
|
928
|
+ // 生成奖励数据
|
|
|
929
|
+ $storeOrderRepository->createRewardMechanismByStoreOrderId($storeOrderEntity->getOrderId());
|
|
|
930
|
+
|
|
|
931
|
+ if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code']) {
|
|
|
932
|
+ // 会员专区的 订单立即结算
|
|
|
933
|
+ $settlementOrderIdList[] = $storeOrderEntity->getOrderId();
|
|
|
934
|
+ }
|
|
|
935
|
+ // 获取当前 订单绑定的购物车
|
|
|
936
|
+ $cartEntity = $cartEntityMap[$storeOrderEntity->getCartId()];
|
|
|
937
|
+ // 准备订单的 状态数据
|
|
|
938
|
+ $storeOrderStatusEntityList[] = StoreOrderStatusEntity::newInstance()
|
|
|
939
|
+ ->setOrderId($storeOrderEntity->getOrderId())
|
|
|
940
|
+ ->setChangeType(StoreOrderStatusEnum::CHANGE_TYPE['PaySuccess']['code'])
|
|
|
941
|
+ ->setChangeMessage(StoreOrderStatusEnum::CHANGE_TYPE['PaySuccess']['name']);
|
|
|
942
|
+
|
|
|
943
|
+ $financialRecordDataList[] = [
|
|
|
944
|
+
|
|
|
945
|
+ ];
|
|
|
946
|
+ }
|
|
|
947
|
+
|
|
|
948
|
+ // 4.6 订单操作记录表
|
|
|
949
|
+ /** @var StoreOrderStatusRepository $storeOrderStatusRepository */
|
|
|
950
|
+ $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
|
|
951
|
+ $storeOrderStatusRepository->createByEntityList($storeOrderStatusEntityList);
|
|
|
952
|
+
|
|
|
953
|
+ if (!empty($settlementOrderIdList)) {
|
|
|
954
|
+ // 将订单 生成的奖励数据 立即结算(发放)
|
|
|
955
|
+ $storeOrderRepository->settlementOrderByOrderIdList($settlementOrderIdList);
|
|
|
956
|
+ }
|
|
|
957
|
+ }
|
|
|
958
|
+
|
|
|
959
|
+ /**
|
|
|
960
|
+ * @param int $groupOrderId
|
|
|
961
|
+ * @param string $rand
|
|
301
|
962
|
* @return int
|
|
302
|
963
|
* @throws DbException
|
|
303
|
964
|
*/
|
|
304
|
|
- public function paySuccess($groupOrderId): int
|
|
|
965
|
+ public function paySuccessUpdateDB(int $groupOrderId, string $rand = ''): int
|
|
305
|
966
|
{
|
|
306
|
|
- return $this->dao->paySuccess($groupOrderId);
|
|
|
967
|
+ return $this->dao->paySuccessUpdateDB($groupOrderId, $rand);
|
|
307
|
968
|
}
|
|
308
|
969
|
}
|