OrderSheetService.php 780 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace app\admin\service\order;
  3. use app\model\GoodsRunning;
  4. use app\model\OrderSheet;
  5. use support\Log;
  6. class OrderSheetService
  7. {
  8. public static function addGoodsSales($orderId)
  9. {
  10. Log::info('开始加销售量', ['order_id' => $orderId]);
  11. try {
  12. $sheets = OrderSheet::where('join_sheet_order_id', $orderId)->select('join_sheet_goods_id', 'order_sheet_num')->get()->toArray();
  13. foreach ($sheets as $sheet) {
  14. GoodsRunning::where('join_running_goods_id', $sheet['join_sheet_goods_id'])->increment('goods_running_sale', $sheet['order_sheet_num']);
  15. }
  16. } catch (\Exception $e) {
  17. Log::error("加销售量失败", ['msg' => $e->getMessage(), 'order_id' => $orderId]);
  18. }
  19. }
  20. }