|
|
@@ -17,7 +17,7 @@ use app\common\model\GroupUser as GroupUserModel;
|
|
|
use app\api\controller\GroupUser as GroupUserController;
|
|
|
use app\common\model\ShopDelivery as ShopDeliveryModel;
|
|
|
use app\common\model\WorkerOut as WorkerOutModel;
|
|
|
-
|
|
|
+use app\common\model\PackSpecs as PackSpecsModel;
|
|
|
/**
|
|
|
* 打包工人相关接口
|
|
|
*/
|
|
|
@@ -109,6 +109,7 @@ class Worker extends Base
|
|
|
if ($result) {
|
|
|
$insert_data['order_status'] = 1;
|
|
|
$insert_data['remark'] = '录入成功';
|
|
|
+ $insert_data['spec_id'] = $sql_data['spec_id'];
|
|
|
} else {
|
|
|
$insert_data['remark'] = '录入失败';
|
|
|
}
|
|
|
@@ -214,54 +215,30 @@ class Worker extends Base
|
|
|
$pid = $this->userinfo['id'];
|
|
|
$where[] = ['sl.user_id', '=', $pid];
|
|
|
|
|
|
- $sql = $scanLog->alias('sl')
|
|
|
- ->join("shop_delivery sd", "sl.code = sd.waybill_no", "INNER")
|
|
|
- ->where('order_status', 1)
|
|
|
- ->where($where);
|
|
|
- // 总件数
|
|
|
- $this->quantity_sum = $sql->sum('num');
|
|
|
- // 总工价
|
|
|
- $this->labor_cost_money_sum = $scanLog->alias('sl')
|
|
|
+
|
|
|
+ $list = $scanLog->alias('sl')
|
|
|
->join("shop_delivery sd", "sl.code = sd.waybill_no", "INNER")
|
|
|
->where('sl.order_status', 1)
|
|
|
+ ->where('sl.spec_id','<>', null)
|
|
|
->where($where)
|
|
|
- ->value("SUM(COALESCE(sd.num,0) * COALESCE(sd.labor_cost_money,0)) as total_labor_cost");
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $list = $groupUserModel
|
|
|
- ->where('pid', '=', $pid)
|
|
|
- ->field('id,pid,nickname')
|
|
|
+ ->field("sl.code,sl.spec_id,SUM(COALESCE(sd.num,0) * 1) as spec_quantity_sum,SUM(COALESCE(sd.num,0) * COALESCE(sd.labor_cost_money,0)) as spec_labor_cost_money_sum")
|
|
|
+ ->group('sl.spec_id')
|
|
|
->select()->each(function ($item, $key) {
|
|
|
- $state = $this->get_worker_out_state($item['id'], $this->userinfo['id'],$this->time);
|
|
|
- $state = $state == 0 ? false : true;
|
|
|
-
|
|
|
- // $item['selected']=$state;
|
|
|
- if ($state) {
|
|
|
- $this->worker_num++;
|
|
|
- $this->worker_list[]=$item;
|
|
|
- }
|
|
|
-
|
|
|
+ $spec_name = $this->get_order_info($item['code']);
|
|
|
+ $item['spec_name']=$spec_name;
|
|
|
+ unset($item['code']);
|
|
|
});
|
|
|
- // 工价平均值
|
|
|
- $quantity_sum = strval($this->labor_cost_money_sum);
|
|
|
- $num = strval($this->worker_num);
|
|
|
- $labor_cost_money_avg = bcdiv($quantity_sum, $num, 2);
|
|
|
-
|
|
|
- // 件数平均值
|
|
|
- $quantity_avg = strval($this->quantity_sum);
|
|
|
- $this->worker_num = strval($this->worker_num);
|
|
|
- $quantity_avg = bcdiv($quantity_avg, $this->worker_num, 2);
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $spec_quantity_sum=$item['spec_quantity_sum'];
|
|
|
+ $spec_labor_cost_money_sum=$item['spec_labor_cost_money_sum'];
|
|
|
+ $this->quantity_sum=bcadd($this->quantity_sum, $spec_quantity_sum,0);
|
|
|
+ $this->labor_cost_money_sum=bcadd($this->labor_cost_money_sum, $spec_labor_cost_money_sum,2);
|
|
|
+ }
|
|
|
|
|
|
$data = [
|
|
|
'quantity_sum' => $this->quantity_sum,
|
|
|
'labor_cost_money_sum' => $this->labor_cost_money_sum,
|
|
|
- 'quantity_avg' => $quantity_avg,
|
|
|
- 'labor_cost_money_avg' => $labor_cost_money_avg,
|
|
|
- 'worker_list' => empty($this->worker_list) ? [] : $this->worker_list
|
|
|
+ 'list' => empty($list) ? [] :$list
|
|
|
|
|
|
|
|
|
];
|
|
|
@@ -287,4 +264,9 @@ class Worker extends Base
|
|
|
}
|
|
|
return $workerOutModel->where($where)->count();
|
|
|
}
|
|
|
+ public function get_order_info($waybill_no){
|
|
|
+ return $this->shopDeliveryModel->where('waybill_no',$waybill_no)->value('spec_name');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|