diff --git a/app/backend/modules/survey/controllers/SurveyController.php b/app/backend/modules/survey/controllers/SurveyController.php
index abbfceb2..564f0f35 100644
--- a/app/backend/modules/survey/controllers/SurveyController.php
+++ b/app/backend/modules/survey/controllers/SurveyController.php
@@ -908,6 +908,7 @@ class SurveyController extends BaseController{
'ims_yz_withdraw_rich_text',
'ims_yz_help_center_content',
'ims_yz_rich_text',
+ 'ims_yz_wechat_menu',
// 经销商相关
diff --git a/app/common/modules/orderGoods/OrderGoodsCollection.php b/app/common/modules/orderGoods/OrderGoodsCollection.php
index 7afdcce2..ac882585 100644
--- a/app/common/modules/orderGoods/OrderGoodsCollection.php
+++ b/app/common/modules/orderGoods/OrderGoodsCollection.php
@@ -46,6 +46,12 @@ class OrderGoodsCollection extends Collection
});
}
+ public function getLegumesPriceTotal(){
+ return $this->sum(function (PreOrderGoods $orderGoods) {
+ return $orderGoods->getUseLegumesPrice();
+ });
+ }
+
/**
* 获取会员价
* @return int
diff --git a/app/common/modules/orderGoods/models/PreOrderGoodsTrait.php b/app/common/modules/orderGoods/models/PreOrderGoodsTrait.php
index 53dff1de..b3f65953 100644
--- a/app/common/modules/orderGoods/models/PreOrderGoodsTrait.php
+++ b/app/common/modules/orderGoods/models/PreOrderGoodsTrait.php
@@ -213,6 +213,10 @@ trait PreOrderGoodsTrait
return $this->getPriceCalculator()->getLegumes();
}
+ public function getUseLegumesPrice(){
+ return $this->getPriceCalculator()->getLegumesPrice();
+ }
+
/**
* 原始价格
* @return mixed
diff --git a/app/common/modules/trade/models/Trade.php b/app/common/modules/trade/models/Trade.php
index f78a40f8..68066aff 100644
--- a/app/common/modules/trade/models/Trade.php
+++ b/app/common/modules/trade/models/Trade.php
@@ -71,10 +71,12 @@ class Trade extends BaseModel
$this->balance = $member->credit2 ?: 0;
// 判断:当前订单是否为文创豆兑换商品
$this->use_legumes_exchange_total = $this->orders->sum('use_legumes_total');
+ $this->use_legumes_price_total = $this->orders->sum('use_legumes_price');
$this->is_allow_exchange = 0;// 是否允许兑换 默认不允许
if($this->use_legumes_exchange_total > 0){
- $holdGoodsLegumes = CulturalSpace::uniacid()->where('uid',$member->uid)->value('goods_legumes');
- $this->is_allow_exchange = (int)($holdGoodsLegumes >= $this->use_legumes_exchange_total);
+ // $holdGoodsLegumes = CulturalSpace::uniacid()->where('uid',$member->uid)->value('goods_legumes');
+ $holdGoodsLegumesPrice = CulturalSpace::uniacid()->where('uid',$member->uid)->value('goods_legumes_money');
+ $this->is_allow_exchange = (int)($holdGoodsLegumesPrice >= $this->use_legumes_price_total);
}
event(new AfterTradeCreatedEvent($this));
diff --git a/app/frontend/modules/order/models/PreOrder.php b/app/frontend/modules/order/models/PreOrder.php
index 11813ee5..6e5fa839 100644
--- a/app/frontend/modules/order/models/PreOrder.php
+++ b/app/frontend/modules/order/models/PreOrder.php
@@ -508,8 +508,9 @@ class PreOrder extends Order
'rise_type' => $this->getRequest()->input('rise_type'),//收件人或单位
'collect_name' => $this->getRequest()->input('call'),//抬头或单位名称
'company_number' => $this->getRequest()->input('company_number'),//单位识别号
- // 使用的文创豆总数
+ // 使用的文创豆兑换相关
'use_legumes_total' => $this->getLegumesTotal(),// 获取使用的文创豆总数
+ 'use_legumes_price' => $this->getLegumesPriceTotal(),// 获取使用的兑换额度
];
$attributes = array_merge($this->getAttributes(),$attributes);
$this->setRawAttributes($attributes);
diff --git a/app/frontend/modules/order/models/PreOrderTrait.php b/app/frontend/modules/order/models/PreOrderTrait.php
index 643ba685..34592d18 100644
--- a/app/frontend/modules/order/models/PreOrderTrait.php
+++ b/app/frontend/modules/order/models/PreOrderTrait.php
@@ -64,9 +64,15 @@ trait PreOrderTrait
return $this->goods_price = $this->orderGoods->getPrice();
}
+ // 文创豆兑换 - 获取使用的豆
public function getLegumesTotal(){
return $this->use_legumes_total = $this->orderGoods->getLegumesTotal();
}
+ // 文创豆兑换 - 获取使用的兑换额度
+ public function getLegumesPriceTotal(){
+ return $this->use_legumes_price = $this->orderGoods->getLegumesPriceTotal();
+ }
+
/**
* 统计订单商品会员价金额
* @return int
diff --git a/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php b/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php
index d4b931bf..cd740482 100644
--- a/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php
+++ b/app/frontend/modules/orderGoods/price/option/BaseOrderGoodsPrice.php
@@ -119,10 +119,20 @@ abstract class BaseOrderGoodsPrice extends OrderGoodsPrice
return $this->use_legumes_exchange;
}
+ return 0;
+ }
+
+ public function getLegumesPrice(){
+ if((int)request()->input('is_legumes_exchange') == 1){
+ $this->use_legumes_exchange_price = GoodsCulturalSpace::uniacid()->where('goods_id',(int)$this->orderGoods->goods_id)->value('legumes_exchange_price');
+
+ return $this->use_legumes_exchange_price;
+ }
return 0;
}
+
//todo blank 商品价格适配器
public function goodsPriceManager()
{
diff --git a/plugins/cultural-space/src/admin/LegumesController.php b/plugins/cultural-space/src/admin/LegumesController.php
index 3e5f9cb4..4259a82c 100644
--- a/plugins/cultural-space/src/admin/LegumesController.php
+++ b/plugins/cultural-space/src/admin/LegumesController.php
@@ -87,6 +87,7 @@ class LegumesController extends BaseController{
$info = CulturalSpaceLegumesWithdrawal::find($id);
$uid = $info->uid;
$buyGoodsNum = (float)$info->buy_goods_num;
+ $buyGoodsNumMoney = (float)$info->buy_goods_num_money;
$realityAmount = $info->reality_amount;
$month = $info->created_at->format('Ym');
// 修改状态
@@ -103,7 +104,10 @@ class LegumesController extends BaseController{
$result = (new ExternalApi())->salaryModelOutOrder($info);
if((int)$result['respCode'] != 2) throw new ShopException($result['respDesc']);
// 商品兑换豆 到账
- (new CulturalSpaceGoodsLegumes())->changeHandle((int)$uid,$buyGoodsNum,1,"易出申请转换",0,['legumes_withdrawal_id' => $id]);
+ (new CulturalSpaceGoodsLegumes())->changeHandle((int)$uid,$buyGoodsNum,1,"易出申请转换",0,[
+ 'legumes_withdrawal_id' => $id,
+ 'change_money' => $buyGoodsNumMoney
+ ]);
DB::commit();
return $this->successJson('打款成功');
diff --git a/plugins/cultural-space/src/api/IndexController.php b/plugins/cultural-space/src/api/IndexController.php
index c0d5bccb..ba6028d5 100644
--- a/plugins/cultural-space/src/api/IndexController.php
+++ b/plugins/cultural-space/src/api/IndexController.php
@@ -241,6 +241,7 @@ class IndexController extends ApiController{
return $this->successJson('success',[
'voucher_number' => $culturalSpaceInfo->voucher_number,
'goods_legumes' => $culturalSpaceInfo->goods_legumes,
+ 'goods_legumes_money' => $culturalSpaceInfo->goods_legumes_money,
'commission_rate' => $withdrawalCommissionRate,
'task_video_link' => $set['task_video_link']
]);
diff --git a/plugins/cultural-space/src/listener/OrderPaidListener.php b/plugins/cultural-space/src/listener/OrderPaidListener.php
index 55a438a5..3af19d98 100644
--- a/plugins/cultural-space/src/listener/OrderPaidListener.php
+++ b/plugins/cultural-space/src/listener/OrderPaidListener.php
@@ -22,6 +22,7 @@ class OrderPaidListener{
if($model->use_legumes_total > 0) {
(new CulturalSpaceGoodsLegumes())->changeHandle((int)$model->uid,(float)$model->use_legumes_total,0,"兑换商品使用",1,[
'order_id' => $model->id ?? 0,// 订单id
+ 'change_money' => $model->use_legumes_price
]);
}
// 订单支付成功奖励贡献值
diff --git a/plugins/cultural-space/src/models/CulturalSpaceGoodsLegumes.php b/plugins/cultural-space/src/models/CulturalSpaceGoodsLegumes.php
index 72939923..fd0053ed 100644
--- a/plugins/cultural-space/src/models/CulturalSpaceGoodsLegumes.php
+++ b/plugins/cultural-space/src/models/CulturalSpaceGoodsLegumes.php
@@ -44,8 +44,10 @@ class CulturalSpaceGoodsLegumes extends BaseModel{
public function changeHandle(int $uid,float $changeNum,int $changeType,string $remark,int $changeSource = 1,array $params = []){
// 获取当前用户持有数量
$changeFront = (float)CulturalSpace::uniacid()->where('uid',$uid)->value('goods_legumes');
+ $changeFrontMoney = (float)CulturalSpace::uniacid()->where('uid',$uid)->value('goods_legumes_money');
// 变更后的数量
$changeAfter = $changeType == 1 ? $changeFront + $changeNum : $changeFront - $changeNum;
+ $changeAfterMoney = $changeType == 1 ? $changeFrontMoney + $params['change_money'] : $changeFrontMoney - $params['change_money'];
// 变更记录
$data = [
'uniacid' => \YunShop::app()->uniacid,
@@ -61,10 +63,16 @@ class CulturalSpaceGoodsLegumes extends BaseModel{
'remark' => $remark,
'created_at' => time(),// 变更时间
'source' => $changeSource,
+ 'change_quantity_money' => $params['change_money'] ?? 0,// 具体变更金额
+ 'change_front_money' => $changeFrontMoney ?? 0,// 变更前拥有的金额
+ 'change_after_money' => $changeAfterMoney ?? 0,// 变更后拥有的金额
];
$id = $this->insertGetId($data);
// 修改用户持有
- CulturalSpace::uniacid()->where('uid',$uid)->update(['goods_legumes' => $changeAfter]);
+ CulturalSpace::uniacid()->where('uid',$uid)->update([
+ 'goods_legumes' => $changeAfter,
+ 'goods_legumes_money' => $changeAfterMoney,
+ ]);
return $id;
}
diff --git a/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php b/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php
index 184b412b..f7ebb2bf 100644
--- a/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php
+++ b/plugins/cultural-space/src/models/CulturalSpaceLegumesWithdrawal.php
@@ -95,20 +95,30 @@ class CulturalSpaceLegumesWithdrawal extends BaseModel{
$culturalFund = CulturalFund::uniacid()->first();
$currentFee = $culturalFund->current_fee;
$reality_amount = (float)sprintf("%.2f",$reality_num * $currentFee);// 实际打款数量
+ // 计算金额
+ $fund_num_money = (float)sprintf("%.2f",$fund_num * $currentFee );// 基金池部分
+ $buy_goods_num_money = (float)sprintf("%.2f",$buy_goods_num * $currentFee );// 购物部分
+ $withdrawal_num_money = (float)sprintf("%.2f",$withdrawal_num * $currentFee );// 易出部分
+ $commission_num_money = (float)sprintf("%.2f",$commission_num * $currentFee );// 手续费
+
// 记录
$data = [
'uniacid' => \YunShop::app()->uniacid,
'uid' => $uid,
- 'withdrawal_total_num' => $totalNum, // 文创豆提现总数
+ 'withdrawal_total_num' => $totalNum, // 文创豆提现总数(豆)
'fund_ratio' => $fundRatio, // 基金池比例
- 'fund_num' => $fund_num, // 基金池数量
+ 'fund_num' => $fund_num, // 基金池数量(豆)
+ 'fund_num_money' => $fund_num_money, // 基金池数量(元)
'buy_goods_ratio' => $buyGoodsRatio, // 购物豆部分比例
- 'buy_goods_num' => $buy_goods_num, // 购物豆部分数量
+ 'buy_goods_num' => $buy_goods_num, // 购物豆部分数量(豆)
+ 'buy_goods_num_money' => $buy_goods_num_money, // 购物豆部分数量(元)
'withdrawal_ratio' => $withdrawalRatio, // 易出部分比例
- 'withdrawal_num' => $withdrawal_num, // 易出数量
+ 'withdrawal_num' => $withdrawal_num, // 易出数量(豆)
+ 'withdrawal_num_money' => $withdrawal_num_money, // 易出数量(元)
'commission_ratio' => $commissionRatio, // 手续费比例
- 'commission_num' => $commission_num, // 手续费数量
- 'reality_num' => $reality_num, // 实际易出文创豆
+ 'commission_num' => $commission_num, // 手续费数量(豆)
+ 'commission_num_money' => $commission_num_money, // 手续费数量(元)
+ 'reality_num' => $reality_num, // 实际易出文创豆(豆)
'current_fee' => $currentFee, // 费率
'reality_amount' => $reality_amount, // 实际提现打款数量(元)
'status' => 0, // 审核状态:0=待审核,1=待打款,2=已驳回
diff --git a/plugins/cultural-space/src/models/GoodsCulturalSpace.php b/plugins/cultural-space/src/models/GoodsCulturalSpace.php
index 9ee58233..9b0287b3 100644
--- a/plugins/cultural-space/src/models/GoodsCulturalSpace.php
+++ b/plugins/cultural-space/src/models/GoodsCulturalSpace.php
@@ -61,7 +61,7 @@ class GoodsCulturalSpace extends BaseModel{
$result = self::uniacid()
->select(['id','goods_id','legumes_exchange_price'])
->with(['belongsToGoods'=>function($query){
- $query->select(['id','title','thumb']);
+ $query->select(['id','title','thumb','price']);
}])
->where('is_open',1)
->where('is_legumes_exchange',1)
@@ -76,8 +76,9 @@ class GoodsCulturalSpace extends BaseModel{
// 计算需要使用的文创豆
$fundInfo = CulturalFund::getfund();
$currentFee = $fundInfo['current_fee'];
- $holdExchangeLegumes = (float)CulturalSpace::uniacid()->where('uid',$uid)->value('goods_legumes');// 当前用户持有的用以兑换商品的文创豆
- $data['data'] = array_map(function($item) use ($currentFee,$holdExchangeLegumes){
+ // $holdExchangeLegumes = (float)CulturalSpace::uniacid()->where('uid',$uid)->value('goods_legumes');// 当前用户持有的用以兑换商品的文创豆
+ $holdExchangeLegumesMoney = (float)CulturalSpace::uniacid()->where('uid',$uid)->value('goods_legumes_money');// 当前用户持有的兑换额度
+ $data['data'] = array_map(function($item) use ($currentFee,$holdExchangeLegumesMoney){
// 使用的文创豆
$useLegumes = ceil($item['legumes_exchange_price'] / $currentFee);
$useLegumes = $useLegumes <= 1 ? 1 : $useLegumes;
@@ -87,8 +88,9 @@ class GoodsCulturalSpace extends BaseModel{
'legumes_exchange_price' => $item['legumes_exchange_price'],
'goods_title' => $item['belongs_to_goods']['title'],
'goods_thumb' => $item['belongs_to_goods']['thumb'],
+ 'goods_price' => $item['belongs_to_goods']['price'],
'use_legumes' => $useLegumes,
- 'is_allow_exchange' => (int)$holdExchangeLegumes >= $useLegumes,
+ 'is_allow_exchange' => (int)$holdExchangeLegumesMoney >= $item['legumes_exchange_price'],
];
},$data['data']);
diff --git a/plugins/cultural-space/views/legumes/withdrawal_apply.blade.php b/plugins/cultural-space/views/legumes/withdrawal_apply.blade.php
index ca766b23..e85cbc67 100644
--- a/plugins/cultural-space/views/legumes/withdrawal_apply.blade.php
+++ b/plugins/cultural-space/views/legumes/withdrawal_apply.blade.php
@@ -88,29 +88,37 @@
-
+
+
+ [[scope.row.withdrawal_total_num]]豆
+
+
[[scope.row.fund_ratio]]%
[[scope.row.fund_num]]豆
+ [[scope.row.fund_num_money]]元
[[scope.row.withdrawal_ratio]]%
[[scope.row.withdrawal_num]]豆
+ [[scope.row.withdrawal_num_money]]元
[[scope.row.buy_goods_ratio]]%
[[scope.row.buy_goods_num]]豆
+ [[scope.row.buy_goods_num_money]]元
[[scope.row.commission_ratio]]%
[[scope.row.commission_num]]豆
+ [[scope.row.commission_num_money]]元