|
@@ -284,22 +284,7 @@ class SportsBagService extends Service
|
|
|
$emp_map = Employee::whereIn('id',$emp_id)
|
|
|
->pluck('emp_name','id')
|
|
|
->toArray();
|
|
|
- $product = [];
|
|
|
- if(! empty($ergs['product'])){
|
|
|
- $sales_p_info = SportsBagProductInfo::where('del_time',0)
|
|
|
- ->whereIn('sports_bag_id',array_column($data['data'],'id'))
|
|
|
- ->get()->toArray();
|
|
|
- $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
|
|
|
- foreach ($sales_p_info as $value){
|
|
|
- $tmp = $map[$value['product_id']] ?? [];
|
|
|
- $value['title'] = $tmp['title'] ?? "";
|
|
|
- $value['code'] = $tmp['code'] ?? "";
|
|
|
- $value['size'] = $tmp['size'] ?? "";
|
|
|
- $value['unit'] = $tmp['unit'] ?? "";
|
|
|
- $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
- $product[$value['sports_bag_id']][] = $value;
|
|
|
- }
|
|
|
- }
|
|
|
+ list($product_price, $product) = $this->getProductMessage(array_column($data['data'],'id'), $ergs);
|
|
|
|
|
|
//订单状态数据组织
|
|
|
$state_array = $this->getStateMake($data['data']);
|
|
@@ -312,12 +297,45 @@ class SportsBagService extends Service
|
|
|
$data['data'][$key]['crt_name'] = $emp_map[$value['crt_id']] ?? '';
|
|
|
$data['data'][$key]['state_title'] = $this->makeState($data['data'][$key], $state_array);
|
|
|
$data['data'][$key]['product'] = $product[$value['id']] ?? [];
|
|
|
+ $data['data'][$key]['ori_total_amount'] = $product_price[$value['id']] ?? 0;
|
|
|
$data['data'][$key]['is_attribute_title'] = SportsBag::$attribute_name[$value['is_attribute']] ?? "";
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ public function getProductMessage($sports_bag_id = [], $data){
|
|
|
+ $product_price = $product_message = [];
|
|
|
+ if(empty($sports_bag_id)) return [$product_price, $product_message];
|
|
|
+ $sales_p_info = SportsBagProductInfo::where('del_time',0)
|
|
|
+ ->whereIn('sports_bag_id', $sports_bag_id)
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ //产品信息
|
|
|
+ $map = [];
|
|
|
+ if(! empty($data['product'])) $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
|
|
|
+
|
|
|
+ foreach ($sales_p_info as $value){
|
|
|
+ if(! empty($data['product'])){
|
|
|
+ $tmp = $map[$value['product_id']] ?? [];
|
|
|
+ $value['title'] = $tmp['title'] ?? "";
|
|
|
+ $value['code'] = $tmp['code'] ?? "";
|
|
|
+ $value['size'] = $tmp['size'] ?? "";
|
|
|
+ $value['unit'] = $tmp['unit'] ?? "";
|
|
|
+ $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
+ $product_message[$value['sports_bag_id']][] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ $tmp = bcmul($value['retail_price'], $value['number'], 2);
|
|
|
+ if(isset($product_price[$value['sports_bag_id']])){
|
|
|
+ $product_price[$value['sports_bag_id']] = bcadd($tmp, $product_price[$value['sports_bag_id']],2);
|
|
|
+ }else{
|
|
|
+ $product_price[$value['sports_bag_id']] = $tmp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [$product_price, $product_message];
|
|
|
+ }
|
|
|
+
|
|
|
public function makeState($value, $state_array){
|
|
|
$nowStamp = time();
|
|
|
if(! empty($state_array[$value['order_number']])){
|