Merge pull request 'dev' (#34) from dev into main

Reviewed-on: #34
This commit is contained in:
mkm 2024-07-06 18:36:35 +08:00
commit 943ac77f6f
13 changed files with 61 additions and 24 deletions

View File

@ -76,7 +76,7 @@ class UserLogic extends BaseLogic
}
}
public static function StoreAdd(array $params)
public static function checkAddress(array $params)
{
$user_ship=$params['user_ship']??0;
if($user_ship==2){
@ -106,6 +106,11 @@ class UserLogic extends BaseLogic
}
}
}
return true;
}
public static function StoreAdd(array $params)
{
self::checkAddress($params);
$passwordSalt = Config::get('project.unique_identification');
$password = create_password(123456, $passwordSalt);
$defaultAvatar = config('project.default_image.admin_avatar');

View File

@ -34,6 +34,7 @@ class PayController extends BaseApiController
$attach = $ciphertext['attach'];
switch ($attach) {
case 'recharge':
Cache::set('6logR' . time(), json_encode($ciphertext));
PayNotifyLogic::handle('recharge', $ciphertext['out_trade_no'], $ciphertext);
$app->wechat->success();
break;

View File

@ -89,6 +89,12 @@ class StoreController extends BaseApiController
return $this->fail(UserUserLogic::getError());
}
}else{
if(isset($params['type']) && $params['type'] != 2){
UserUserLogic::checkAddress($params);
if(UserUserLogic::hasError()){
return $this->fail(UserUserLogic::getError());
}
}
$find['real_name']=$params['real_name'];
$find['label_id']=$params['label_id']??0;
$find->save();
@ -127,12 +133,13 @@ class StoreController extends BaseApiController
$order = UserRecharge::create($data);
$order['pay_price']=$order['price'];
$order['attach']=$order['recharge'];
$order['attach']='recharge';
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
if (PaymentLogic::hasError()) {
return $this->fail(PaymentLogic::getError());
}
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
Cache::set('trade_state' . time(), json_encode($result));
PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result);
} else {
Redis::send('send-code-pay', ['order_id' => $order['order_id'],'pay_type'=>'recharge']);
@ -156,7 +163,7 @@ class StoreController extends BaseApiController
UserRecharge::where('id', $id)->update(['order_id'=>$order_id]);
$order['order_id']=$order_id;
$order['pay_price']=$order['price'];
$order['attach']=$order['recharge'];
$order['attach']='recharge';
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
if (PaymentLogic::hasError()) {
return $this->fail(PaymentLogic::getError());

View File

@ -28,6 +28,7 @@ use app\api\lists\user\UserRechargeLists;
$arr = [
[
'money'=>1000,//采购包
// 'money'=>1,//采购包
'send'=>249,//礼品券
'money_string'=>$buy_bar,
'send_string'=>$send_bar,

View File

@ -111,7 +111,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
'msg' => '您已选购满500元支付成功后即可获得'.bcmul($this->total_price,0.1,2).'元品牌礼品兑换券,可到线下门店兑换礼品。',
'pay_price' => $this->total_price
];
if($this->off_activity==1){
if($this->off_activity==0){//1
$this->activity_price = $this->total_price;
$data['pay_price']=$this->activity_price;
if($this->activity_price<500){

View File

@ -54,6 +54,7 @@ class OrderLogic extends BaseLogic
public static $store_price; //门店零售价
public static $activity_price;
public static $deduction_price;
public static $frozen_money;//返还金额
/**
* @notes 获取购物车商品信息
@ -76,6 +77,7 @@ class OrderLogic extends BaseLogic
self::$activity_price = 0; //活动减少
self::$store_price = 0; //商户价
self::$deduction_price =0;
self::$frozen_money =0;//返还金额
$deduction_price = 0; //抵扣金额
/** 计算价格 */
$off_activity = Config::where('name', 'off_activity')->value('value');
@ -142,6 +144,7 @@ class OrderLogic extends BaseLogic
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价
self::$deduction_price=bcadd(self::$deduction_price,$deduction_price,2);//抵扣金额
self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2);//返还金额
// self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
}
//加支付方式限制
@ -169,6 +172,7 @@ class OrderLogic extends BaseLogic
'activity_price' => self::$activity_price,
'activities' => self::$activity_price > 0 ? 1 : 0,
'deduction_price' => self::$deduction_price,
'frozen_money' => self::$frozen_money,//返还金额(活动关闭得时候有)
'source' => 0,
'is_storage' => $params['is_storage'] ?? 0,
];

View File

@ -170,8 +170,10 @@ class CommissionLogic extends BaseLogic
//记录用户余额收入
if ($uid) {
$GiveUser = User::where('id', $order['uid'])->find();
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
if($GiveUser['user_ship'] != 5){//新限制 不为种养殖
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
}
}
$financeLogic->user['uid'] = $order['uid'];
$financeLogic->other_arr['vip_uid'] = $uid;

View File

@ -437,6 +437,11 @@ class PayNotifyLogic extends BaseLogic
$order->save();
$uid = $order->uid;
$user = User::where('id', $uid)->findOrEmpty();
//check store_id
if(empty($user->store_id)){
$user->store_id = $order['store_id'];
}
//用户的财务add
$capitalFlowDao = new CapitalFlowLogic($user);
$capitalFlowDao->userIncome('user_balance_recharge', 'user_recharge', $order['id'], $price, [], 1);

View File

@ -3,11 +3,13 @@
namespace app\common\logic;
use app\common\enum\YesNoEnum;
use app\common\logic\BaseLogic;
use app\common\model\user\User;
use app\common\model\user_recharge\UserRecharge;
use app\common\model\user_sign\UserSign;
use app\common\model\user_sign_log\UserSignLog;
use function Symfony\Component\String\s;
/**
* 会员积分逻辑
@ -42,7 +44,7 @@ class UserSignLogic extends BaseLogic
if($total_vip==0){
return false;
}
$count = UserRecharge::where('uid', $order->uid)->count();
$count = UserRecharge::where(['uid'=>$order->uid,'paid'=>YesNoEnum::YES])->count();
if ($count ==1 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) {
//首充
$write = self::write($order, $total_vip, 0, 1, 9);

View File

@ -105,7 +105,7 @@ class IndexController extends BaseLikeController
*/
public function sales_ranking()
{
$time = $this->request->get('date', date('Y-m-d'));
$time = $this->request->get('date');
$store_id = $this->store_id;
$where = [];
if ($store_id) {

View File

@ -26,7 +26,7 @@ class OrderLogic extends BaseLogic
];
return $data;
}
public static function Currday($where,$date)
public static function Currday($where, $date)
{
$startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳
$endTime = strtotime($date . ' 23:59:59'); // 当天的结束时间戳
@ -56,32 +56,36 @@ class OrderLogic extends BaseLogic
}
return $data;
}
public static function dayPayPrice($where,$time)
public static function dayPayPrice($where, $time)
{
$todayAmount = UserRecharge::where($where)
->whereDay('create_time',$time)
->whereDay('create_time', $time)
->sum('price');
$pay_price = StoreOrder::where($where)
->whereDay('create_time',$time)
->whereDay('create_time', $time)
->sum('pay_price');
return bcadd($todayAmount, $pay_price, 2);
}
public static function dealFlexiblePrice($where,$start,$end)
public static function dealFlexiblePrice($where, $start, $end)
{
//排除退款
$todayAmount = UserRecharge::where($where)->where('status',1)
$todayAmount = UserRecharge::where($where)->where('status', 1)
->whereBetweenTime('create_time', $start, $end)
->sum('price');
$pay_price = StoreOrder::where($where)->where('refund_status',0)
$pay_price = StoreOrder::where($where)->where('refund_status', 0)
->whereBetweenTime('create_time', $start, $end)
->sum('pay_price');
return bcadd($todayAmount, $pay_price, 2);
}
public static function sales($where,$time){
$select=StoreOrder::where($where)->whereDay('create_time',$time)->limit(10)->order('id desc')->field('id,order_id,pay_price,create_time')->select();
public static function sales($where, $time)
{
$select = StoreOrder::where($where);
if ($time) {
$select->whereDay('create_time', $time);
}
$select = $select->limit(20)->order('id desc')->field('id,order_id,pay_price,create_time')->select();
return $select?->toArray();
}
}

View File

@ -8,6 +8,7 @@ use app\api\logic\order\OrderLogic;
use app\api\validate\OrderValidate;
use app\common\model\order\Cart;
use app\common\model\user\User;
use app\common\model\user_sign\UserSign;
use app\store\lists\store_order\StoreOrderLists;
use app\common\controller\Definitions;
use app\common\enum\PayEnum;
@ -399,10 +400,14 @@ class StoreOrderController extends BaseAdminController
return $this->fail('支付条码不能为空');
}
$params = $this->request->post();
UserShipLogic::user_ship($params);
if(UserShipLogic::hasError()){
return $this->fail(UserShipLogic::getError());
$count = UserRecharge::where('uid',$params['uid'])->where('paid',1)->count();
if($count < 1){
UserShipLogic::user_ship($params);
if(UserShipLogic::hasError()){
return $this->fail(UserShipLogic::getError());
}
}
$data = [
'store_id' => $this->adminInfo['store_id'],
'uid' => $params['uid'],

View File

@ -11,6 +11,7 @@ use app\common\model\user\User;
use app\common\model\user_ship\UserShip;
use app\common\lists\ListsSearchInterface;
use app\common\model\user\UserAddress;
use app\common\model\user_sign_log\UserSignLog;
use app\common\model\vip_flow\VipFlow;
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
@ -62,12 +63,12 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface
where(['user_id'=>$data['id'],'status'=>0])
->sum('number')??0;
$data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number');
$number1 = UserSign::where('uid',$data['id'])->where('status',1)->where('type','<>',3)->sum('number');
$number2 = UserSign::where('uid',$data['id'])->where('status',1)->where('type',3)->sum('number');
$number1 = UserSignLog::where('uid',$data['id'])->where(['status'=>1,'order_type'=>0,'financial_pm'=>1])->sum('number');
$number2 = UserSignLog::where('uid',$data['id'])->where(['status'=>1,'order_type'=>0,'financial_pm'=>0])->sum('number');
if($number1<$number2){
$data['get_frozen']=0;
}else{
$data['get_frozen']=bcsub($number1,$number2,2)??0;
$data['get_frozen']=bcsub($number2,$number1,2)??0;
}
})->toArray();