40 lines
1009 B
PHP
40 lines
1009 B
PHP
<?php
|
|
namespace app\api\logic\operation;
|
|
use app\common\logic\BaseLogic;
|
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
|
use think\facade\Db;
|
|
|
|
class OpurchaseGoodsOfferLogic extends BaseLogic{
|
|
|
|
|
|
public static function offer($params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
foreach ($params['data'] as $v){
|
|
OpurchaseGoodsOffer::where('id',$v['id'])->update([
|
|
'price' => $v['price'],
|
|
'nums' => $v['nums'],
|
|
'is_adopt' => 1,
|
|
'update_time' => time()
|
|
]);
|
|
}
|
|
$id=$params['data'][0]['id']??0;
|
|
if($id){
|
|
$find=OpurchaseGoodsOffer::where('id',$params['data'][0]['id'])->field('supplier_id','create_time')->find();
|
|
if($find){
|
|
$time=date('Y-m-d',$find['create_time']);
|
|
Db::name('opurchase_goods_offer_date')->where('supplier_id', $find['supplier_id'])->whereDay('create_time',$time)->update(['status'=>1]);
|
|
}
|
|
}
|
|
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
}
|