链街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.

51 lines
1.5 KiB

  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 StoreAccount extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. protected $table = 'ims_cjdc_store_account';
  10. public static $tableName = 'ims_cjdc_store_account';
  11. protected $dateFormat = 'U';
  12. public $timestamps = false;
  13. /**
  14. * 添加店铺流水
  15. * @param $oid //主订单id
  16. */
  17. public function addStoreAccount($oid,$type=1,$note='线上订单')
  18. {
  19. $accountData = $data = [];
  20. $orderData = DB::table('ims_cjdc_order')->where('order_main_id',$oid)->get()->toArray();
  21. if (count($orderData)) {
  22. foreach ($orderData as $item) {
  23. if (is_object($item)){
  24. $accountData['user_id'] = $item->user_id;
  25. $accountData['order_id'] = $item->id;
  26. $accountData['store_id'] = $item->store_id;
  27. $accountData['money'] = $item->money;
  28. $accountData['type'] = $type;
  29. $accountData['note'] = $note;
  30. $accountData['add_time'] = time();
  31. $accountData['time'] = date('Y-m-d H:i:s', time());
  32. $data[] = $accountData;
  33. }
  34. }
  35. return DB::table('ims_cjdc_store_account')->insert($data);
  36. } else {
  37. return false;
  38. }
  39. }
  40. }