|
|
@@ -214,7 +214,7 @@ class OrderService extends BaseService
|
|
|
// 用户信息
|
|
|
RedisService::set($cacheLockKey, ['params' => $params, 'user_id' => $userId], rand(3, 5));
|
|
|
$userInfo = MemberModel::where(['id' => $userId, 'mark' => 1])
|
|
|
- ->select(['id', 'openid', 'buy_type', 'bd_score', 'status'])
|
|
|
+ ->select(['id', 'openid','nickname','member_level','parent_id','point_id','points', 'buy_type','property','balance', 'bd_score', 'status'])
|
|
|
->first();
|
|
|
$status = isset($userInfo['status']) ? $userInfo['status'] : 0;
|
|
|
$openid = isset($userInfo['openid']) ? $userInfo['openid'] : 0;
|
|
|
@@ -422,10 +422,18 @@ class OrderService extends BaseService
|
|
|
if(!AccountLogModel::insertGetId($data)){
|
|
|
Db::rollBack();
|
|
|
$this->error = '付款处理失败';
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 佣金数据
|
|
|
+ if(!$commission = SettleService::make()->commissionCount($order, $userInfo, $type)){
|
|
|
+ Db::rollBack();
|
|
|
+ $this->error = '订单处理失败';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
// 获取支付参数
|
|
|
/* TODO 支付处理 */
|
|
|
$payOrder = [
|
|
|
@@ -771,18 +779,19 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 订单信息
|
|
|
- $info = $this->model->with(['orderGoods'])->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id', 'order_no', 'user_id', 'store_id', 'meeting_id', 'pay_total', 'bonus', 'delivery_no', 'delivery_company', 'delivery_code', 'status'])
|
|
|
+ $info = $this->model->with(['orderGoods','commission'])->where(['id' => $id, 'mark' => 1])
|
|
|
+ ->select(['id', 'order_no','type', 'user_id', 'store_id', 'total', 'pay_total', 'delivery_no', 'delivery_company', 'delivery_code', 'status'])
|
|
|
->first();
|
|
|
$orderNo = isset($info['order_no']) ? $info['order_no'] : '';
|
|
|
$deliveryNo = isset($info['delivery_no']) ? $info['delivery_no'] : '';
|
|
|
$deliverCompany = isset($info['delivery_company']) ? $info['delivery_company'] : '';
|
|
|
$orderUserId = isset($info['user_id']) ? $info['user_id'] : 0;
|
|
|
$storeId = isset($info['store_id']) ? $info['store_id'] : 0;
|
|
|
- $meetingId = isset($info['meeting_id']) ? $info['meeting_id'] : 0;
|
|
|
- $orderTotal = isset($info['pay_total']) ? $info['pay_total'] : 0;
|
|
|
- $bonus = isset($info['bonus']) ? $info['bonus'] : 0;
|
|
|
+ $orderType = isset($info['type']) ? $info['type'] : 0;
|
|
|
+ $orderTotal = isset($info['total']) ? $info['total'] : 0;
|
|
|
$status = isset($info['status']) ? $info['status'] : 0;
|
|
|
+ $commission = isset($info['commission']) ? $info['commission'] : [];
|
|
|
+ $bonus = isset($commission['bonus'])?$commission['bonus'] : 0;
|
|
|
$orderGoods = isset($info['order_goods']) ? $info['order_goods'] : [];
|
|
|
if (empty($info) || empty($orderNo)) {
|
|
|
$this->error = '订单信息不存在';
|
|
|
@@ -806,7 +815,8 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
- $updateData = ['status' => 4, 'complete_at' => date('Y-m-d H:i:s'), 'update_time' => time()];
|
|
|
+ $completeStatus = env('ORDER_COMPLETE_STATUS', 5);
|
|
|
+ $updateData = ['status' => $completeStatus, 'complete_at' => date('Y-m-d H:i:s'), 'update_time' => time()];
|
|
|
if (!$check) {
|
|
|
$updateData['is_complete'] = 1;
|
|
|
$updateData['complete_remark'] = '自动收货';
|
|
|
@@ -833,22 +843,29 @@ class OrderService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 结算商家收益
|
|
|
- if (SettleService::make()->storeBonus($storeId, $bonus, $info) < 0) {
|
|
|
+ if ($bonus && SettleService::make()->storeBonus($storeId, $bonus, $info) < 0) {
|
|
|
DB::rollBack();
|
|
|
$this->error = SettleService::make()->getError();
|
|
|
RedisService::clear($cacheLockKey);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 关联会议统计
|
|
|
- if ($meetingId) {
|
|
|
- // 会议成交统计
|
|
|
- $updateData = ['order_count' => DB::raw('order_count+1'), 'order_total' => DB::raw("order_total + {$orderTotal}")];
|
|
|
- MeetingModel::where(['id' => $meetingId])->update($updateData);
|
|
|
-
|
|
|
- // 签到用户成交统计
|
|
|
- $updateData = ['order_count' => DB::raw('order_count+1'), 'order_total' => DB::raw("order_total + {$orderTotal}")];
|
|
|
- MeetingRecordsModel::where(['meeting_id' => $meetingId, 'user_id' => $orderUserId])->update($updateData);
|
|
|
+ if($orderType==2){
|
|
|
+ // 创业礼包结算
|
|
|
+ if (SettleService::make()->businessBonus($orderUserId, $orderTotal, $commission, $info) < 0) {
|
|
|
+ DB::rollBack();
|
|
|
+ $this->error = SettleService::make()->getError();
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 商城奖励结算
|
|
|
+ if (SettleService::make()->shopBonus($orderUserId, $orderTotal,$commission, $info) < 0) {
|
|
|
+ DB::rollBack();
|
|
|
+ $this->error = SettleService::make()->getError();
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|