链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7 KiB

5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Support\Facades\DB;
  6. class ImsCjdcOrderMain extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. //protected $table = 'ims_cjdc_order_main';
  10. protected $table = 'lanzu_order_main';
  11. public $timestamps = false;
  12. public function imsCjdcUser()
  13. {
  14. return $this->hasOne('\App\Models\ImsCjdcUser','id','user_id');
  15. }
  16. public function market()
  17. {
  18. return $this->hasOne('\App\Models\ImsCjdcMarket','id','market_id');
  19. }
  20. /**
  21. * 同时变更主订单和子订单状态,
  22. * @param $oid //主订单id
  23. * @param $state //订单状态
  24. */
  25. public function modifyState($oid,$state)
  26. {
  27. return DB::transaction(function () use ($oid,$state){
  28. $data1['state'] = $data2['state'] = $state;
  29. $data1['update_time'] = time();
  30. if ($state == 4) {
  31. $data1['complete_time'] = $data2['complete_time'] = time();
  32. } elseif ($state == 3) {
  33. $data1['jd_time'] = $data2['jd_time'] = time();
  34. }
  35. DB::table('ims_cjdc_order_main')
  36. ->where('id',$oid)
  37. ->update($data1);
  38. DB::table('ims_cjdc_order')
  39. ->where('order_main_id',$oid)
  40. ->update($data2);
  41. if ($state==4){
  42. //添加店铺流水记录
  43. $account = new StoreAccount();
  44. $account->addStoreAccount($oid);
  45. }
  46. return true;
  47. });
  48. }
  49. public function updateShippingType($oid,$type)
  50. {
  51. return self::where('id',$oid)->update(['order_shipping_code'=>$type]);
  52. }
  53. }