|
@@ -1658,100 +1658,6 @@ class StatisticsService extends Service
|
|
|
return array_column($product,'id');
|
|
|
}
|
|
|
|
|
|
- //--------------------------脚本
|
|
|
- public function inoutrecord(){return;
|
|
|
- $in_data = InvoiceOrder::where('del_time',0)
|
|
|
- ->select('id','sales_order_id')
|
|
|
- ->get()->toArray();
|
|
|
-
|
|
|
- $map = [];
|
|
|
- $s_p = SalesOrderProductInfo::whereIn('sales_order_id',array_column($in_data,'sales_order_id'))
|
|
|
- ->where('del_time',0)
|
|
|
- ->select('sales_order_id','product_id','final_amount','price')
|
|
|
- ->get()->toArray();
|
|
|
- foreach ($s_p as $value){
|
|
|
- $map[$value['sales_order_id']][] = [
|
|
|
- 'product_id' => $value['product_id'],
|
|
|
- 'final_amount' => $value['final_amount'],
|
|
|
- 'price' => $value['price'],
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- foreach ($in_data as $value){
|
|
|
- $tmp = $map[$value['sales_order_id']] ?? [];
|
|
|
- if(empty($tmp)) continue;
|
|
|
- foreach ($tmp as $val){
|
|
|
- InvoiceOrderInfo::where('del_time',0)
|
|
|
- ->where('invoice_id', $value['id'])
|
|
|
- ->where('product_id', $val['product_id'])
|
|
|
- ->update([
|
|
|
- 'final_amount' => $val['final_amount'],
|
|
|
- 'price' => $val['price'],
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }catch (\Throwable $exception){
|
|
|
- DB::rollBack();
|
|
|
- dd($exception->getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- dd(1);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public function inoutrecord2(){return;
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- DB::table('in_out_record')
|
|
|
- ->where('price',0)
|
|
|
- ->whereIn('order_type', array_values(ReturnExchangeOrder::$prefix))
|
|
|
- ->select('id','order_number','product_id')
|
|
|
- ->orderBy('id','asc')
|
|
|
- ->chunk(200,function ($data) {;
|
|
|
- $data = Collect($data)->map(function ($object) {
|
|
|
- return (array)$object;
|
|
|
- })->toArray();
|
|
|
-
|
|
|
- $map = ReturnExchangeOrder::where('del_time',0)
|
|
|
- ->whereIn('order_number',array_column($data,'order_number'))
|
|
|
- ->pluck('id','order_number')
|
|
|
- ->toArray();
|
|
|
- $result = ReturnExchangeOrderProductInfo::where('del_time',0)
|
|
|
- ->whereIn('return_exchange_id',array_values($map))
|
|
|
- ->select('return_exchange_id','return_exchange_price','product_id')
|
|
|
- ->get()->toArray();
|
|
|
- $result_map = [];
|
|
|
- foreach ($result as $v){
|
|
|
- $result_map[$v['return_exchange_id']][$v['product_id']] = [
|
|
|
- 'product_id' => $v['product_id'],
|
|
|
- 'price' => $v['return_exchange_price'],
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- foreach ($data as $value){
|
|
|
- $tmp_id = $map[$value['order_number']] ?? 0;
|
|
|
- if($tmp_id < 0) continue;
|
|
|
- $tmp = $result_map[$tmp_id][$value['product_id']] ?? [];
|
|
|
- if(empty($tmp)) continue;
|
|
|
-
|
|
|
- InOutRecord::where('id',$value['id'])->update([
|
|
|
- 'price' => $tmp['price']
|
|
|
- ]);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- DB::commit();
|
|
|
- }catch (\Throwable $exception){
|
|
|
- DB::rollBack();
|
|
|
- dd($exception->getMessage());
|
|
|
- }
|
|
|
- dd(1);
|
|
|
- }
|
|
|
-
|
|
|
public function statisticsAreaDepartProduct222($data,$user){
|
|
|
if(empty($data['crt_time'][0]) || empty($data['crt_time'][1])) return [false, '请选择时间区间'];
|
|
|
$return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|