diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index a34d9a619..b19e9c1e8 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -59,6 +59,7 @@ class Order extends Auth [$items, $order, $truckType] = [[], [], -1]; $order['uid'] = $this->uuid; $order['order_no'] = CodeExtend::uniqidDate(18, 'N'); + $order['amount_rebate'] = 0.00; // 推荐人处理 $order['puid1'] = input('from', $this->user['pid1']); if ($order['puid1'] == $this->uuid) $order['puid1'] = 0; @@ -122,8 +123,6 @@ class Order extends Auth 'price_selling' => $goodsItem['price_selling'], 'total_market' => $goodsItem['price_market'] * $count, 'total_selling' => $goodsItem['price_selling'] * $count, - // 是否参与返利 - 'rebate_type' => $goodsInfo['rebate_type'], // 奖励金额积分 'reward_balance' => $goodsItem['reward_balance'] * $count, 'reward_integral' => $goodsItem['reward_integral'] * $count, @@ -132,11 +131,17 @@ class Order extends Auth 'vip_number' => $this->user['vip_number'], // 是否入会礼包 'vip_entry' => $goodsInfo['vip_entry'], + // 是否参与返利 + 'rebate_type' => $goodsInfo['rebate_type'], // 等级优惠方案 'discount_id' => $discountId, 'discount_rate' => $discountRate, - 'discount_amount' => $discountRate * floatval($goodsItem['price_selling']) * $count / 100, + 'discount_amount' => $discountRate * $goodsItem['price_selling'] * $count / 100, ]; + // 统计订单返利金额 + if ($goodsInfo['rebate_type'] > 0) { + $order['amount_rebate'] += $goodsItem['price_selling'] * $count; + } } try { // 订单发货类型 diff --git a/app/data/service/GoodsService.php b/app/data/service/GoodsService.php index 460994304..0056ce459 100644 --- a/app/data/service/GoodsService.php +++ b/app/data/service/GoodsService.php @@ -16,7 +16,7 @@ class GoodsService extends Service /** * 更新商品库存数据 * @param string $code - * @return bool + * @return boolean * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException @@ -29,7 +29,7 @@ class GoodsService extends Service $stockList = $query->where(['goods_code' => $code])->group('goods_code,goods_spec')->select()->toArray(); // 商品销量统计 $query = $this->app->db->table('shop_order a')->field('b.goods_code,b.goods_spec,ifnull(sum(b.stock_sales),0) stock_sales'); - $query->leftJoin('shop_order_item b', 'a.order_no=b.order_no')->where([['b.goods_code', '=', $code], ['a.status', 'in', [1, 2, 3, 4, 5]]]); + $query->leftJoin('shop_order_item b', 'a.order_no=b.order_no')->where("b.goods_code='{$code}' and a.status>0 and a.deleted>0"); $salesList = $query->group('b.goods_code,b.goods_spec')->select()->toArray(); // 组装更新数据 $dataList = [];