commit
f16910691f
@ -84,26 +84,20 @@ class UserLogic extends BaseLogic
|
||||
self::setError('请设置村参数');
|
||||
return false;
|
||||
}
|
||||
$arr=User::where('user_ship',$user_ship)->column('id');
|
||||
if($arr){
|
||||
$find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find();
|
||||
if($find){
|
||||
$arr=User::where('user_ship',$user_ship)->alias('user')->join('user_address address','user.id=address.uid and village='.$params['village'])->find();
|
||||
if ($arr) {
|
||||
self::setError('该区域已有村长请重新选择');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}elseif($user_ship==3){
|
||||
if(!isset($params['brigade'])){
|
||||
self::setError('请设置队参数');
|
||||
return false;
|
||||
}
|
||||
$arr=User::where('user_ship',$user_ship)->column('id');
|
||||
$arr=User::where('user_ship',$user_ship)->alias('user')->join('user_address address','user.id=address.uid and village='.$params['village'] .' and brigade='.$params['brigade'])->find();
|
||||
if($arr){
|
||||
$find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->where('brigade',$params['brigade'])->find();
|
||||
if($find){
|
||||
self::setError('该区域已有队长请重新选择');
|
||||
return false;
|
||||
}
|
||||
self::setError('该区域已有队长请重新选择');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -3,7 +3,8 @@
|
||||
namespace app\api\controller\product;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\product\ProductLists;
|
||||
|
||||
use app\api\lists\product\StoreProductLists;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
|
||||
class ProductController extends BaseApiController{
|
||||
public $notNeedLogin = ['lists'];
|
||||
@ -22,5 +23,18 @@ class ProductController extends BaseApiController{
|
||||
$this->request->__set('store_id',$this->request->userInfo['store_id']??0);
|
||||
return $this->dataLists(new ProductLists());
|
||||
}
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
public function store_lists(){
|
||||
|
||||
$store_id=SystemStoreStaff::where('uid',$this->userId)->where('is_admin',1)->value('store_id');
|
||||
if($store_id>0){
|
||||
$this->request->__set('store_id',$store_id);
|
||||
return $this->dataLists(new StoreProductLists());
|
||||
}else{
|
||||
return $this->dataLists();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ class StoreController extends BaseApiController
|
||||
$params = (new UserValidate())->post()->goCheck('rechargeStoreMoney');
|
||||
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||
$recharge_type = $this->request->post('recharge_type',''); //微信支付条码
|
||||
$code = $this->request->post('code','');//验证码
|
||||
$phone = $params['mobile'];
|
||||
// $code = $this->request->post('code','');//验证码
|
||||
// $phone = $params['mobile'];
|
||||
// if($code && $phone){
|
||||
// $remark = $phone.'_reporting';
|
||||
// $codeCache = Cache::get($remark);
|
||||
@ -84,12 +84,18 @@ class StoreController extends BaseApiController
|
||||
$find=User::where('account|mobile',$params['mobile'])->find();
|
||||
if(!$find){
|
||||
$params['create_uid']=$this->userId;
|
||||
if(isset($params['user_ship']) && in_array($params['user_ship'],[2,3])){
|
||||
UserUserLogic::checkAddress($params);
|
||||
if(UserUserLogic::hasError()){
|
||||
return $this->fail(UserUserLogic::getError());
|
||||
}
|
||||
}
|
||||
$find=UserUserLogic::StoreAdd($params);
|
||||
if(UserUserLogic::hasError()){
|
||||
return $this->fail(UserUserLogic::getError());
|
||||
}
|
||||
}else{
|
||||
if(isset($params['type']) && $params['type'] != 2){
|
||||
if($find['user_ship']!=$params['user_ship'] && in_array($params['user_ship'],[2,3])){
|
||||
UserUserLogic::checkAddress($params);
|
||||
if(UserUserLogic::hasError()){
|
||||
return $this->fail(UserUserLogic::getError());
|
||||
@ -130,6 +136,7 @@ class StoreController extends BaseApiController
|
||||
'recharge_type'=>'INDUSTRYMEMBERS',
|
||||
'user_ship'=>$params['user_ship']??0,
|
||||
];
|
||||
d(123123);
|
||||
$order = UserRecharge::create($data);
|
||||
|
||||
$order['pay_price']=$order['price'];
|
||||
|
@ -1,60 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller\user;
|
||||
namespace app\api\controller\user;
|
||||
|
||||
use app\api\lists\user\UserFeedbackLists;
|
||||
use app\api\logic\user\UserFeedbackLogic;
|
||||
use app\admin\validate\user\UserFeedbackValidate;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\user\UserFeedbackLists;
|
||||
use app\api\logic\user\UserFeedbackLogic;
|
||||
use app\admin\validate\user\UserFeedbackValidate;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\user\UserRechargeLists;
|
||||
use app\common\model\dict\DictData;
|
||||
|
||||
class UserRechargeController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @notes 获取用户充值
|
||||
* @return \support\Response
|
||||
* @author likeadmin
|
||||
* @date 2024/05/13 16:56
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new UserRechargeLists());
|
||||
}
|
||||
class UserRechargeController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @notes 获取用户充值
|
||||
* @return \support\Response
|
||||
* @author likeadmin
|
||||
* @date 2024/05/13 16:56
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new UserRechargeLists());
|
||||
}
|
||||
|
||||
public function recharge_list()
|
||||
{
|
||||
$buy_bar = "元采购包";
|
||||
$send_bar = "品牌礼品券";
|
||||
$arr = [
|
||||
[
|
||||
'money'=>1000,//采购包
|
||||
// 'money'=>1,//采购包
|
||||
'send'=>249,//礼品券
|
||||
'money_string'=>$buy_bar,
|
||||
'send_string'=>$send_bar,
|
||||
],
|
||||
[
|
||||
'money'=>2000,//采购包
|
||||
'send'=>560,//礼品券
|
||||
'money_string'=>$buy_bar,
|
||||
'send_string'=>$send_bar,
|
||||
],
|
||||
[
|
||||
'money'=>5000,//采购包
|
||||
'send'=>1550,//礼品券
|
||||
'money_string'=>$buy_bar,
|
||||
'send_string'=>$send_bar,
|
||||
],
|
||||
[
|
||||
'money'=>10000,//采购包
|
||||
'send'=>3500,//礼品券
|
||||
'money_string'=>$buy_bar,
|
||||
'send_string'=>$send_bar,
|
||||
]
|
||||
];
|
||||
return $this->success('ok',$arr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public function recharge_list()
|
||||
{
|
||||
$buy_bar = "元采购包";
|
||||
$send_bar = "品牌礼品券";
|
||||
$list = DictData::where('type_value', 'recharge')->select()
|
||||
->each(function($item)use($buy_bar,$send_bar){
|
||||
$item['money'] = $item['value'];
|
||||
$item['money_string'] = $buy_bar;
|
||||
$item['send_string'] = $send_bar;
|
||||
if($item['name']=='level_one'){
|
||||
$item['send'] = 249;
|
||||
}elseif($item['name']=='level_two'){
|
||||
$item['send'] = 560;
|
||||
}elseif($item['name']=='level_three'){
|
||||
$item['send'] = 1550;
|
||||
}elseif($item['name']=='level_four'){
|
||||
$item['send'] = 3500;
|
||||
}
|
||||
});
|
||||
return $this->success('ok', $list?->toArray());
|
||||
}
|
||||
}
|
||||
|
@ -56,15 +56,19 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
|
||||
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select()
|
||||
->each(function ($v) use ($item) {
|
||||
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find();
|
||||
if(empty($find)){
|
||||
$find = StoreProduct::where('id', $v['product_id'])->withTrashed()->find();
|
||||
$v['store_name'] = '';
|
||||
$v['image'] = '';
|
||||
$v['price'] = '';
|
||||
$v['unit_name']='';
|
||||
if(isset($v['cart_info'])){
|
||||
// foreach( $v['cart_info'] as $k=>$vv){
|
||||
$v['store_name'] =$v['cart_info']['name'];
|
||||
$v['image'] =$v['cart_info'] ['image'];
|
||||
$v['price'] = $v['cart_info']['price'];
|
||||
$v['unit_name']=$v['cart_info']['unit_name']??'';
|
||||
// }
|
||||
|
||||
}
|
||||
$v['store_name'] = $find['store_name'];
|
||||
$v['image'] = $find['image'];
|
||||
// $v['price'] = $find['price'];
|
||||
$v['price'] = $v['cart_info']['price'];
|
||||
$v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
|
||||
});
|
||||
$item['goods_count'] = count(explode(',', $item['cart_id']));
|
||||
if ($item['refund_reason_time']) {
|
||||
|
@ -81,6 +81,11 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis
|
||||
}
|
||||
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
if($off_activity==1){
|
||||
$tag='赠10%品牌礼品券';
|
||||
}else{
|
||||
$tag='';
|
||||
}
|
||||
$uid=0;
|
||||
if($this->request->get('uid',0)>0){
|
||||
$uid=$this->request->get('uid',0);
|
||||
@ -102,8 +107,8 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($order)
|
||||
// ->page($this->limitOffset +1,$this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$item['tag']=' 赠10%品牌礼品券 ';
|
||||
->select()->each(function ($item) use($tag){
|
||||
$item['tag']=$tag;
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
|
111
app/api/lists/product/StoreProductLists.php
Normal file
111
app/api/lists/product/StoreProductLists.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\product;
|
||||
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\cate\Cate;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\user\User;
|
||||
//use app\common\model\goods\GoodsLabel;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 商品列表列表
|
||||
* Class goods
|
||||
* @package app\api\goods
|
||||
*/
|
||||
class StoreProductLists extends BaseApiDataLists implements ListsSearchInterface, ListsSortInterface
|
||||
{
|
||||
protected $off_activity = 0;
|
||||
protected $user_ship = 0;
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/04/23 11:28
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
// '=' => ['store_id', 'cate_id', 'top_cate_id', 'two_cate_id'],
|
||||
'%like%' => ['store_name' => 'store_name'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
* @return string[]
|
||||
* @date 2021/12/29 10:07
|
||||
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||
*/
|
||||
public function setSortFields(): array
|
||||
{
|
||||
return ['sell' => 'price', 'sales' => 'sales',];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置默认排序
|
||||
* @return string[]
|
||||
* @date 2021/12/29 10:06
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return ['price' => 'asc', 'id' => 'desc'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取商品列表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/04/23 11:28
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$store_id= $this->request->__get('store_id');
|
||||
if($store_id){
|
||||
$this->searchWhere[] = ['store_id', '=', $store_id];
|
||||
}
|
||||
|
||||
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
$type=$this->request->get('type',0);
|
||||
if($type==1){
|
||||
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
}elseif($type==2){
|
||||
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,vip_price price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
}
|
||||
$this->searchWhere[] = ['status', '=', 1];
|
||||
|
||||
// $this->searchWhere[] = ['stock', '>', 0];
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->field($fields)
|
||||
->with(['className', 'unitName'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取商品列表数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/04/23 11:28
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->count();
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
@ -62,7 +63,7 @@ class OrderLogic extends BaseLogic
|
||||
* @param $params
|
||||
* @return array|bool
|
||||
*/
|
||||
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [])
|
||||
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0)
|
||||
{
|
||||
$where = ['is_pay' => 0];
|
||||
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray();
|
||||
@ -80,16 +81,29 @@ class OrderLogic extends BaseLogic
|
||||
self::$deduction_price = 0;
|
||||
self::$frozen_money = 0; //返还金额
|
||||
$deduction_price = 0; //抵扣金额
|
||||
$fresh_price = 0; //生鲜金额
|
||||
/** 计算价格 */
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id';
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id';
|
||||
foreach ($cart_select as $k => $v) {
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
|
||||
if (!$find) {
|
||||
// unset($cart_select[$k]);
|
||||
// continue;
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id';
|
||||
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id,cate_id';
|
||||
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
|
||||
if ($find) {
|
||||
$cate_id = StoreCategory::where('id', $find['cate_id'])->value('pid');
|
||||
if ($cate_id > 0) {
|
||||
$cate_id = StoreCategory::where('id', $cate_id)->value('pid');
|
||||
if ($cate_id > 0) {
|
||||
$cate_id = StoreCategory::where('id', $cate_id)->value('pid');
|
||||
$find['top_cate_id'] = $cate_id;
|
||||
} else {
|
||||
$find['top_cate_id'] = $cate_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$cart_select[$k]['status'] = 1; //缺货标识
|
||||
}
|
||||
unset($cart_select[$k]['id']);
|
||||
@ -114,6 +128,10 @@ class OrderLogic extends BaseLogic
|
||||
$deduction_price = bcsub($cart_select[$k]['total_price'], $cart_select[$k]['pay_price'], 2);
|
||||
$cart_select[$k]['deduction_price'] = $deduction_price; //抵扣金额
|
||||
}
|
||||
//计算生鲜
|
||||
if ($createOrder == 1 && $find['top_cate_id'] == 15201) {
|
||||
$fresh_price = bcadd($fresh_price, $cart_select[$k]['pay_price']);
|
||||
}
|
||||
$cart_select[$k]['product_id'] = $find['product_id'];
|
||||
$cart_select[$k]['old_cart_id'] = $v['id'];
|
||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
||||
@ -153,7 +171,16 @@ class OrderLogic extends BaseLogic
|
||||
// if ($user && $user['user_ship'] == 1 && $pay_type != 17) {
|
||||
// $pay_price = self::$pay_price;
|
||||
// } else {
|
||||
|
||||
|
||||
$pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
||||
//判断生鲜是否大于200
|
||||
if ($createOrder == 1 && $fresh_price > 0) {
|
||||
if ($pay_price < 200) {
|
||||
self::setError('订单包含生鲜产品,订单金额必须大于200元,才能下单');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// }
|
||||
//成本价 收益
|
||||
$order = [
|
||||
@ -236,7 +263,11 @@ class OrderLogic extends BaseLogic
|
||||
$verify_code = createCode($code);
|
||||
$params['order_id'] = $order_id;
|
||||
$params['verify_code'] = $verify_code;
|
||||
$orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params);
|
||||
$orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params, 1);
|
||||
if ($orderInfo == false) {
|
||||
self::setError(self::getError());
|
||||
return false;
|
||||
}
|
||||
if (!$orderInfo) {
|
||||
return false;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace app\common\logic;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\model\user_sign\UserSign;
|
||||
@ -23,22 +24,38 @@ class UserSignLogic extends BaseLogic
|
||||
*/
|
||||
public static function dealRechargeFrozen($user, $order, $user_ship = 0)
|
||||
{
|
||||
$total_vip = 0;
|
||||
$level_one = 1000;
|
||||
$level_two = 2000;
|
||||
$level_three = 5000;
|
||||
$level_four = 10000;
|
||||
$list = DictData::where('type_value', 'recharge')->select();
|
||||
foreach( $list as $k=>$v){
|
||||
if($v['name']=='level_one'){
|
||||
$level_one = $v['value'];
|
||||
}elseif($v['name']=='level_two'){
|
||||
$level_two = $v['value'];
|
||||
}elseif($v['name']=='level_three' ){
|
||||
$level_three = $v['value'];
|
||||
}elseif($v['name']=='level_four'){
|
||||
$level_four = $v['value'];
|
||||
}
|
||||
}
|
||||
$price=(int)$order['price'];
|
||||
switch ($price) {
|
||||
case 1000:
|
||||
case $level_one:
|
||||
$total_vip = 249;
|
||||
break;
|
||||
case 2000:
|
||||
case $level_two:
|
||||
$total_vip = 560;
|
||||
break;
|
||||
case 5000:
|
||||
case $level_three:
|
||||
$total_vip = 1550;
|
||||
break;
|
||||
case 10000:
|
||||
case $level_four:
|
||||
$total_vip = 3500;
|
||||
break;
|
||||
default:
|
||||
$total_vip = 0;
|
||||
break;
|
||||
}
|
||||
if($total_vip==0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user