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.
53 lines
1.6 KiB
53 lines
1.6 KiB
<?php
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Models\ImsCjdcStore as storeModel;
|
|
|
|
class StoreAccount extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
protected $table = 'ims_cjdc_store_account';
|
|
protected $dateFormat = 'U';
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* 添加店铺流水
|
|
* @param $oid //主订单id
|
|
*/
|
|
public function addStoreAccount($oid,$type=1,$note='线上订单')
|
|
{
|
|
$accountData = $data = [];
|
|
$orderData = DB::table('ims_cjdc_order')->where('order_main_id',$oid)->get()->toArray();
|
|
|
|
if (count($orderData)) {
|
|
foreach ($orderData as $item) {
|
|
if (is_object($item)){
|
|
$accountData['user_id'] = $item->user_id;
|
|
$accountData['order_id'] = $item->id;
|
|
$accountData['store_id'] = $item->store_id;
|
|
$accountData['money'] = $item->money;
|
|
$accountData['type'] = $type;
|
|
$accountData['note'] = $note;
|
|
$accountData['add_time'] = time();
|
|
$accountData['time'] = date('Y-m-d H:i:s', time());
|
|
$data[] = $accountData;
|
|
}
|
|
}
|
|
return DB::table('ims_cjdc_store_account')->insert($data);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function store(){
|
|
return $this->hasMany(storeModel::class,'id','store_id');
|
|
}
|
|
}
|