|
|
@@ -13,6 +13,12 @@ class Shops extends Base
|
|
|
{
|
|
|
//protected $noNeedLogin = ['*'];
|
|
|
|
|
|
+ //发货数量汇总、重量汇总
|
|
|
+ public function getCount(ShopDelivery $shopDelivery)
|
|
|
+ {
|
|
|
+ $result = $shopDelivery->field('sum(num) total_num,sum(weigh) total_weight')->where('user_id', $this->userinfo['id'])->find();
|
|
|
+ $this->success('ok', $result);
|
|
|
+ }
|
|
|
|
|
|
//发货记录
|
|
|
public function delivery(ShopDelivery $shopDelivery){
|
|
|
@@ -20,16 +26,25 @@ class Shops extends Base
|
|
|
$plat_id = $this->request->post('plat_id/d', 0); //平台
|
|
|
$shop_id = $this->request->post('shop_id/d', 0); //店铺
|
|
|
$variety_id = $this->request->post('variety_id/d', 0); //品种
|
|
|
+ $spec_id = $this->request->post('spec_id/d', 0); //规格
|
|
|
+ $customer = $this->request->post('customer_name/s', ''); //客户
|
|
|
+ $num = $this->request->post('num/d', 0); //数量
|
|
|
+
|
|
|
$limit = $this->request->post('limit/d', 15); //条数
|
|
|
$where['a.user_id'] = $this->userinfo['id'];
|
|
|
if($plat_id > 0) $where['a.plat_id'] = $plat_id;
|
|
|
if($shop_id > 0) $where['a.shop_id'] = $shop_id;
|
|
|
if($variety_id > 0) $where['a.variety_id']= $variety_id;
|
|
|
+ if($spec_id > 0) $where['a.spec_id'] = $spec_id;
|
|
|
+ if(!empty($customer)) $where['customer_name'] = ['like', '%'.$customer.'%'];
|
|
|
+ if($num > 0) $where['a.num']= $num;
|
|
|
+
|
|
|
$result = $shopDelivery::alias('a')
|
|
|
->leftjoin('shop_list b', 'a.shop_id = b.id') //店铺
|
|
|
->leftjoin('stock_config c', 'a.variety_id = c.id') //品种
|
|
|
->leftjoin('product_config d', 'a.spec_id = d.id') //规格
|
|
|
- ->field('a.id,a.plat_id,a.shop_id,a.createtime,a.num, b.name shop_name,c.title variety_name,d.title spec_name')
|
|
|
+ ->leftjoin('customer u', 'a.customer_id = u.id') //客户
|
|
|
+ ->field('a.id,a.plat_id,a.shop_id,a.createtime,a.num, b.name shop_name,c.title variety_name,d.title spec_name,u.name customer_name')
|
|
|
->where($where)
|
|
|
->paginate($limit);
|
|
|
$this->success('ok', $result);
|
|
|
@@ -63,7 +78,59 @@ class Shops extends Base
|
|
|
$this->error(__('没有新增任何数据'));
|
|
|
}
|
|
|
$this->success();
|
|
|
+ }
|
|
|
|
|
|
+ //编辑录入
|
|
|
+ public function deliveryedit(SpecService $specService)
|
|
|
+ {
|
|
|
+ $data = $this->request->post();
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ validate(ShopValidate::class)->scene('edit')->check($data);
|
|
|
+
|
|
|
+ $result = $specService::getDeliveryEdit($this->userinfo['id'], $data);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ }catch (ValidateException $e) {
|
|
|
+
|
|
|
+ return $this->error($e->getError());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($result === false) {
|
|
|
+ $this->error(__('没有新增任何数据'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //删除录入
|
|
|
+ public function deliverydel(ShopDelivery $shopDelivery, SpecService $specService)
|
|
|
+ {
|
|
|
+ $data = $this->request->post();
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ validate(ShopValidate::class)->scene('del')->check($data);
|
|
|
+
|
|
|
+ $result = $specService::getDeliveryDel($this->userinfo['id'], $data);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ }catch (ValidateException $e) {
|
|
|
+
|
|
|
+ return $this->error($e->getError());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($result === false) {
|
|
|
+ $this->error(__('没有新增任何数据'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
}
|
|
|
|
|
|
|