|
|
@@ -115,7 +115,7 @@ class TradeService extends BaseService
|
|
|
$query->where('a.sell_uid', '=', $sellUid);
|
|
|
}
|
|
|
})
|
|
|
- ->select(['a.*', 'b.nickname', 'b.mobile as buy_mobile', 'c.nickname as sell_nickname', 'c.mobile as sell_mobile', 'g.goods_name', 'g.code', 'g.thumb'])
|
|
|
+ ->select(['a.*', 'b.nickname', 'b.mobile as buy_mobile', 'c.nickname as sell_nickname', 'c.mobile as sell_mobile', 'g.goods_name', 'g.code','g.price', 'g.thumb'])
|
|
|
->orderBy('a.pay_time', 'desc')
|
|
|
->orderBy('a.id', 'desc')
|
|
|
->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
@@ -692,7 +692,11 @@ class TradeService extends BaseService
|
|
|
public function sellConfirm($params)
|
|
|
{
|
|
|
$id = isset($params['id']) ? $params['id'] : 0;
|
|
|
- $info = $this->model->where(['id' => $id, 'mark' => 1])->first();
|
|
|
+ $info = $this->model->from('trade as a')
|
|
|
+ ->leftJoin('goods as b','b.id','=','a.goods_id')
|
|
|
+ ->where(['a.id' => $id, 'a.mark' => 1])
|
|
|
+ ->select(['a.*','b.split_price','b.split_num'])
|
|
|
+ ->first();
|
|
|
if (empty($id) || empty($info)) {
|
|
|
$this->error = 2042;
|
|
|
return false;
|
|
|
@@ -712,18 +716,20 @@ class TradeService extends BaseService
|
|
|
|
|
|
// 判断是否可以上架或拆分
|
|
|
$realPrice = $info['real_price'];
|
|
|
- $price = $info['price']; // 特价
|
|
|
- $addPrice = $realPrice*$priceRate/100;
|
|
|
+ $sellPrice = $info['sell_price']; // 特价
|
|
|
+ $price = $info['price']; // 买入价格
|
|
|
+ $price1 = $info['new_price']; // 买入价格
|
|
|
+ $addPrice = intval($realPrice*$priceRate/100,0);
|
|
|
|
|
|
// 满足涨价上架
|
|
|
- if($price+$addPrice < $info['split_price']){
|
|
|
- if (!$this->model->where(['id' => $id])->update(['status' => 4,'new_price'=> $price+$addPrice,'real_price'=> $realPrice + $addPrice, 'is_sell' => 2, 'update_time' => time()])) {
|
|
|
+ if($price1+$addPrice < $info['split_price']){
|
|
|
+ if (!$this->model->where(['id' => $id])->update(['status' => 4,'new_price'=> $price1+$addPrice,'real_price'=> $realPrice + $addPrice, 'is_sell' => 1, 'update_time' => time()])) {
|
|
|
$this->error = 2056;
|
|
|
DB::rollBack();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (!GoodsModel::where(['id' => $info['goods_id']])->update(['last_sell_time'=>time(),'real_price' => $realPrice + $addPrice, 'price' => $price+$addPrice,'is_trade'=> 2, 'update_time' => time()])) {
|
|
|
+ if (!GoodsModel::where(['id' => $info['goods_id']])->update(['last_sell_time'=>time(), 'price' => $price1+$addPrice,'is_trade'=> 2, 'update_time' => time()])) {
|
|
|
$this->error = 2056;
|
|
|
DB::rollBack();
|
|
|
return false;
|
|
|
@@ -735,7 +741,7 @@ class TradeService extends BaseService
|
|
|
}
|
|
|
// 停止拆分
|
|
|
else if($info['sell_price'] == $stopSplitPrice){
|
|
|
- if (!GoodsModel::where(['id' => $id])->update(['status' => 2,'stop_split'=>1, 'update_time' => time()])) {
|
|
|
+ if (!GoodsModel::where(['id' => $info['goods_id']])->update(['status' => 2,'split_stop'=>1, 'update_time' => time()])) {
|
|
|
$this->error = 2054;
|
|
|
DB::rollBack();
|
|
|
return false;
|
|
|
@@ -743,12 +749,12 @@ class TradeService extends BaseService
|
|
|
|
|
|
$this->error = 2064;
|
|
|
DB::commit();
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
// 满足拆分
|
|
|
- else {
|
|
|
- if(!GoodsService::make()->split($info['goods_id'])){
|
|
|
+ else if($info['split_price']) {
|
|
|
+ if(!GoodsService::make()->split($info['goods_id'], $info)){
|
|
|
$this->error = 2058;
|
|
|
DB::rollBack();
|
|
|
return false;
|