@ -385,6 +385,7 @@ class CommunityRepository extends BaseRepository
|
||||
}
|
||||
if ($data['product_info'] && $data['is_type'] == self::COMMUNITY_TYPE_ENTRUST) {
|
||||
$this->entrust($community->community_id, $data['product_info'], $data['entrust_mer_id'] ?? 0, $data['entrust_day'] ?? 0);
|
||||
Db::name('community')->where('community_id', $community->community_id)->update(['entrust_mer_id' => $data['entrust_mer_id'] ?? 0]);
|
||||
}
|
||||
event('community.create',compact('community'));
|
||||
return $community->community_id;
|
||||
|
@ -500,7 +500,7 @@ class Community extends BaseController
|
||||
$count = $queryBuilder->count();
|
||||
$list = $queryBuilder->setOption('field', [])->field(['c.community_id', 'c.title', 'c.image', 'c.resale_type', 'c.mer_status', 'SUM(`r`.`number` * `r`.`price`) AS total_price', 'SUM(`r`.`number` * `r`.`price` * (100 - `r`.`float_rate`) / 100) AS discount_price'])->group('c.community_id')->order('c.community_id', 'desc')->page($page, $limit)->fetchSql(false)->select();
|
||||
if ($list) $list = $list->toArray();
|
||||
foreach($list as $k=>&$v) {
|
||||
foreach($list as $k => $v) {
|
||||
$list[$k]['discount_price'] = round($v['discount_price'], 2);
|
||||
}
|
||||
return app('json')->success(compact('count', 'list'));
|
||||
@ -559,7 +559,7 @@ class Community extends BaseController
|
||||
Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update();
|
||||
}
|
||||
Db::name('resale')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'status' => $status, 'mer_status' => 2]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'status' => -1, 'mer_status' => 2]);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
@ -602,7 +602,7 @@ class Community extends BaseController
|
||||
Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update();
|
||||
}
|
||||
Db::name('resale')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->update(['is_del' => 1, 'status' => -1]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->update(['is_del' => 1, 'status' => -2]);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
@ -637,14 +637,16 @@ class Community extends BaseController
|
||||
*/
|
||||
public function checkEntrust($id)
|
||||
{
|
||||
$communityInfo = Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->find();
|
||||
$communityInfo = Db::name('community')->where('community_id', $id)->where('is_del', 0)->find();
|
||||
if (!$communityInfo) {
|
||||
return app('json')->fail('委托商品不存在');
|
||||
}
|
||||
if ($communityInfo['mer_status'] > 0) {
|
||||
return app('json')->fail('该委托商品已审核');
|
||||
}
|
||||
$merchantId = Db::name('merchant')->where('uid', $this->request->uid())->value('mer_id');
|
||||
$entrustInfo = Db::name('entrust')->where('community_id', $id)->where('entrust_mer_id', $merchantId)->where('is_del', 0)->where('status', 0)->fetchSql(false)->find();
|
||||
if (!$entrustInfo) {
|
||||
return app('json')->fail('用户无审核此委托商品权限');
|
||||
if ($merchantId != $communityInfo['entrust_mer_id']) {
|
||||
return app('json')->fail('当前商户无审核此委托商品权限');
|
||||
}
|
||||
$status = $this->request->param('status');
|
||||
if (!$status) {
|
||||
@ -652,10 +654,11 @@ class Community extends BaseController
|
||||
}
|
||||
// 同意
|
||||
if ($status == 1) {
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]);
|
||||
Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['status' => $status, 'mer_status' => 1]);
|
||||
}
|
||||
// 拒绝
|
||||
if ($status == 2) {
|
||||
$refusal = $this->request->param('refusal', '');
|
||||
Db::startTrans();
|
||||
try {
|
||||
$list = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->where('status', 0)->select();
|
||||
@ -664,7 +667,7 @@ class Community extends BaseController
|
||||
Db::name('store_product_attr_value')->where('product_id', $prod['product_id'])->where('unique', $prod['product_attr_unique'])->inc('stock', $prod['number'])->update();
|
||||
}
|
||||
Db::name('entrust')->where('community_id', $id)->where('status', 0)->update(['is_del' => 1]);
|
||||
Db::name('community')->where('uid', $this->request->uid())->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'status' => $status, 'mer_status' => 2]);
|
||||
Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['is_del' => 1, 'refusal' => $refusal, 'status' => -1, 'mer_status' => 2]);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
@ -673,4 +676,51 @@ class Community extends BaseController
|
||||
}
|
||||
return app('json')->success('审核操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 委托商品列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function entrustList()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$status = $this->request->param('status', -1);
|
||||
$type = $this->request->param('type');
|
||||
$queryBuilder = Db::name('community')->alias('c')->leftJoin('merchant m','m.mer_id = c.entrust_mer_id')->where('c.is_type', 4)->where('c.is_del', 0);
|
||||
// type:1发起的委托 2收到的委托
|
||||
if ($type == 1) {
|
||||
$queryBuilder = $queryBuilder->where('c.uid', $this->request->uid());
|
||||
} else {
|
||||
$merchantId = Db::name('merchant')->where('uid', $this->request->uid())->value('mer_id', -1);
|
||||
$queryBuilder = $queryBuilder->where('c.entrust_mer_id', $merchantId);
|
||||
}
|
||||
// 待审核
|
||||
if ($status == 0) {
|
||||
$queryBuilder->where('c.mer_status', 0);
|
||||
}
|
||||
// 审核通过
|
||||
if ($status == 1) {
|
||||
$queryBuilder->where('c.mer_status', 1);
|
||||
}
|
||||
// 审核拒绝
|
||||
if ($status == 2) {
|
||||
$queryBuilder->where('c.mer_status', 2);
|
||||
}
|
||||
$count = $queryBuilder->count();
|
||||
$list = $queryBuilder->setOption('field', [])->field(['c.community_id', 'c.uid', 'c.title', 'c.image', 'c.entrust_mer_id', 'm.credit_buy', 'm.settle_cycle', 'm.interest_rate', 'm.mer_name', 'm.mer_avatar', 'c.mer_status'])->order('c.community_id', 'desc')->page($page, $limit)->fetchSql(false)->select();
|
||||
if ($list) $list = $list->toArray();
|
||||
foreach($list as $k => $v) {
|
||||
$list[$k]['mer_name'] = 0;
|
||||
// type:1发起的委托 2收到的委托
|
||||
if ($type == 2) {
|
||||
$merchantInfo = Db::name('merchant')->where('uid', $v['uid'])->find();
|
||||
$list[$k]['credit_buy'] = $merchantInfo['credit_buy'] ?? 0;
|
||||
$list[$k]['settle_cycle'] = $merchantInfo['settle_cycle'] ?? 0;
|
||||
$list[$k]['interest_rate'] = $merchantInfo['interest_rate'] ?? 0;
|
||||
$list[$k]['mer_name'] = $merchantInfo['mer_name'] ?? '';
|
||||
$list[$k]['mer_avatar'] = $merchantInfo['mer_avatar'] ?? '';
|
||||
}
|
||||
}
|
||||
return app('json')->success(compact('count', 'list'));
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use app\validate\merchant\StoreProductValidate;
|
||||
use crmeb\basic\BaseController;
|
||||
use crmeb\services\UploadService;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
|
@ -118,7 +118,7 @@ class StoreOrder extends BaseController
|
||||
if (!empty($hasCourierData) && is_string($hasCourierData)) {
|
||||
$courierData = json_decode($hasCourierData, true);
|
||||
if (empty($courierData['code']) || $courierData['code'] != 1) {
|
||||
throw new ValidateException('该收货区域未配送快递员');
|
||||
throw new ValidateException('该收货区域未设置快递员');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ use crmeb\basic\BaseController;
|
||||
use app\validate\merchant\StoreProductValidate as validate;
|
||||
use app\common\repositories\store\product\ProductRepository as repository;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
|
||||
class Product extends BaseController
|
||||
{
|
||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 395 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 523 B After Width: | Height: | Size: 523 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 551 B |
Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 471 B |
Before Width: | Height: | Size: 642 B After Width: | Height: | Size: 642 B |
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
Before Width: | Height: | Size: 654 B After Width: | Height: | Size: 654 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 521 B After Width: | Height: | Size: 521 B |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 534 B After Width: | Height: | Size: 534 B |
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 297 B |