@@ -0,0 +1,104 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type MallOrd struct { | |||
OrdId int64 `json:"ord_id" xorm:"not null pk BIGINT(20)"` | |||
MainOrdId int64 `json:"main_ord_id" xorm:"not null comment('主订单号') index BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"comment('用户id') index INT(11)"` | |||
MoneyInAccount int `json:"money_in_account" xorm:"comment('') INT(11)"` | |||
BuyerName string `json:"buyer_name" xorm:"comment('购买人') VARCHAR(255)"` | |||
AppId string `json:"app_id" xorm:"comment('购买人') VARCHAR(255)"` | |||
BuyerPhone string `json:"buyer_phone" xorm:"comment('购买人手机号') VARCHAR(255)"` | |||
CostPrice string `json:"cost_price" xorm:"comment('价格') DECIMAL(12,2)"` | |||
MaocaoPrice string `json:"maocao_price" xorm:"comment('汇率') DECIMAL(12,2)"` | |||
DeductCoin string `json:"deduct_coin" xorm:"comment('抵扣券') DECIMAL(12,2)"` | |||
CostVirtualCoin string `json:"cost_virtual_coin" xorm:"comment('消耗的虚拟币') DECIMAL(12,2)"` | |||
CoinPrice string `json:"coin_price" xorm:"comment('消耗的虚拟币') DECIMAL(12,2)"` | |||
VirtualCoinId int `json:"virtual_coin_id" xorm:"comment('使用的虚拟币id') INT(11)"` | |||
State int `json:"state" xorm:"comment('订单状态:0未支付 1已支付 2已发货 3已完成 4售后中 5部分售后中 6关闭') TINYINT(1)"` | |||
PayTime time.Time `json:"pay_time" xorm:"comment('支付时间') DATETIME"` | |||
PayChannel int `json:"pay_channel" xorm:"not null comment('支付方式:1balance 2alipay 3wx_pay 4澳门工银支付 5澳门工银支付-支付宝支付 6澳门工银支付-微信支付 7') TINYINT(1)"` | |||
ShippingTime time.Time `json:"shipping_time" xorm:"comment('发货时间') DATETIME"` | |||
LogisticCompany string `json:"logistic_company" xorm:"not null default '' comment('物流公司') VARCHAR(255)"` | |||
LogisticNum string `json:"logistic_num" xorm:"not null default '' comment('物流单号') VARCHAR(255)"` | |||
ReceiverPhone string `json:"receiver_phone" xorm:"not null default '' comment('收货人手机号') VARCHAR(20)"` | |||
ReceiverName string `json:"receiver_name" xorm:"not null default '' comment('收货人名字') VARCHAR(255)"` | |||
ReceiverAddressDetail string `json:"receiver_address_detail" xorm:"not null default '' comment('收货人地址') VARCHAR(255)"` | |||
ShippingType int `json:"shipping_type" xorm:"not null default 1 comment('运送方式:1快递送货') TINYINT(1)"` | |||
CouponDiscount string `json:"coupon_discount" xorm:"not null default 0.00 comment('优惠券折扣额') DECIMAL(12,2)"` | |||
DiscountPrice string `json:"discount_price" xorm:"not null default 0.00 comment('立减') DECIMAL(12,2)"` | |||
UserCouponId int64 `json:"user_coupon_id" xorm:"comment('使用的优惠券id') BIGINT(20)"` | |||
ReturnInsuranceFee string `json:"return_insurance_fee" xorm:"not null default 0.00 comment('退货无忧费用') DECIMAL(12,2)"` | |||
IsReceipt int `json:"is_receipt" xorm:"not null default 0 comment('是否开具发票 0否 1是') TINYINT(255)"` | |||
ShippingFee string `json:"shipping_fee" xorm:"not null default 0.00 comment('运费') DECIMAL(12,2)"` | |||
Comment string `json:"comment" xorm:"not null comment('备注') VARCHAR(2048)"` | |||
ProvinceName string `json:"province_name" xorm:"not null default '' comment('收货省份') VARCHAR(255)"` | |||
CityName string `json:"city_name" xorm:"not null default '' comment('收货城市') VARCHAR(255)"` | |||
CountyName string `json:"county_name" xorm:"not null default '' comment('收货区域') VARCHAR(255)"` | |||
PayNum string `json:"pay_num" xorm:"not null default '' comment('交易流水') VARCHAR(255)"` | |||
ConfirmTime time.Time `json:"confirm_time" xorm:"comment('确认时间') DATETIME"` | |||
EstimateIntegral string `json:"estimate_integral" xorm:"not null default 0.0000 comment('预计积分') DECIMAL(12,4)"` | |||
EstimateCommission string `json:"estimate_commission" xorm:"not null default 0.0000 comment('预计佣金') DECIMAL(12,4)"` | |||
CreateTime time.Time `json:"create_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
TeamCheckTime time.Time `json:"team_check_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('') DATETIME"` | |||
IsTeamCheck int `json:"is_team_check" xorm:"comment('商品id') INT(11)"` | |||
UpdateTime time.Time `json:"update_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
DeletedTime time.Time `json:"deleted_time" xorm:"deleted comment('删除时间') DATETIME"` | |||
FinishTime time.Time `json:"finish_time" xorm:"comment('完成时间') DATETIME"` | |||
OrderType int `json:"order_type" xorm:"not null default 1 comment('订单类型:1普通订单 2拼团订单') TINYINT(3)"` | |||
Data string `json:"data" xorm:"comment('订单相关的数据') TEXT"` | |||
GroupBuyCommission string `json:"group_buy_commission" xorm:"default 0.0000 comment('团购未中奖佣金') DECIMAL(12,4)"` | |||
GroupBuySettleTime time.Time `json:"group_buy_settle_time" xorm:"comment('拼团结算时间') DATETIME"` | |||
SettleTime time.Time `json:"settle_time" xorm:"comment('结算时间') DATETIME"` | |||
GroupBuyCommissionTime time.Time `json:"group_buy_commission_time" xorm:"comment('拼团分佣时间') DATETIME"` | |||
CommissionTime time.Time `json:"commission_time" xorm:"comment('分佣时间') DATETIME"` | |||
ShareUid int `json:"share_uid" xorm:"comment('分享人') INT(11)"` | |||
GoodsType int `json:"goods_type" xorm:"comment('商品活动类型') INT(11)"` | |||
IsConsign int `json:"is_consign" xorm:"comment('是否是超级拼团寄售0否1是') TINYINT(1)"` | |||
UserLevelData string `json:"user_level_data" xorm:"comment('会员礼包相关') TEXT"` | |||
GoodsId int `json:"goods_id" xorm:"comment('商品id') INT(11)"` | |||
UserLevel int `json:"user_level" xorm:"comment('升级礼包升级等级') INT(11)"` | |||
IsHasUserLevel int `json:"is_has_user_level" xorm:"comment('是否有会员权益') INT(1)"` | |||
IsGiveUserLevel int `json:"is_give_user_level" xorm:"comment('是否赠送升级礼包') INT(1)"` | |||
SupplierMerchantId int `json:"supplier_merchant_id" xorm:"comment('供应商id') INT(11)"` | |||
SupplierOrdId string `json:"supplier_ord_id" xorm:"comment('供应商订单id') VARCHAR(255)"` | |||
SupplierCloudChainOrdId string `json:"supplier_cloud_chain_ord_id" xorm:"comment('供应商订单1688订单id') VARCHAR(255)"` | |||
SupplierStoreOrdId string `json:"supplier_store_ord_id" xorm:"comment('供应链店铺订单号') VARCHAR(255)"` | |||
Pvd string `json:"pvd" xorm:"comment('') VARCHAR(255)"` | |||
IsSubsidyEnd int `json:"is_subsidy_end" xorm:"comment('') INT(11)"` | |||
PayOnBehalfUid int `json:"pay_on_behalf_uid" xorm:"comment('0') INT(11)"` | |||
ProvinceId string `json:"province_id" xorm:"comment('省id') CHAR(12)"` | |||
CityId string `json:"city_id" xorm:"comment('市id') CHAR(12)"` | |||
CountyId string `json:"county_id" xorm:"comment('县/区') CHAR(11)"` | |||
CurrencyCode string `json:"currency_code" xorm:"default 'CNY' comment('货币符号') VARCHAR(10)"` | |||
TotalShippingFee string `json:"total_shipping_fee" xorm:"default '0.00' comment('供应链同一商家总运费') DECIMAL(12,2)"` | |||
StoreOrdId int64 `json:"store_ord_id" xorm:"not null default '0' comment('店铺主订单号') BIGINT(20)"` | |||
TransactionId string `json:"transaction_id" xorm:"comment('交易号') VARCHAR(255)"` | |||
IcbcIntegral string `json:"icbc_integral" xorm:"comment('澳门工行积分') DECIMAL(12,4)"` | |||
ParentUid int `json:"parent_uid" xorm:"comment('推荐人') INT(11)"` | |||
RewardCoinAmount string `json:"reward_coin_amount" xorm:"comment('') DECIMAL(12,4)"` | |||
IsVirtualGoods int `json:"is_virtual_goods" xorm:"default 0 comment('') INT(1)"` | |||
RewardCoinId int `json:"reward_coin_id" xorm:"default 0 comment('') INT(11)"` | |||
RewardVirtualUserLv string `json:"reward_virtual_user_lv" xorm:"not null comment('自定义参数json') TEXT"` | |||
BaseCommission string `json:"base_commission" xorm:"comment('积分兑换模式基数') DECIMAL(12,4)"` | |||
PlatformCostPrice string `json:"platform_cost_price" xorm:"comment('平台成本价') DECIMAL(12,4)"` | |||
IsSettle int `json:"is_settle" xorm:"default 0 comment('') INT(11)"` | |||
PointId string `json:"point_id" xorm:"comment('澳门自提点id') VARCHAR(20)"` | |||
PickUpId string `json:"pick_up_id" xorm:"comment('自提点id') VARCHAR(20)"` | |||
EndTime int `json:"end_time" xorm:"comment('') INT(11)"` | |||
ConsignForSaleUid int `json:"consign_for_sale_uid" xorm:"comment('') INT(11)"` | |||
ConsignForSaleOid string `json:"consign_for_sale_oid" xorm:"comment('') VARCHAR(20)"` | |||
PickUpUid int `json:"pick_up_uid" xorm:"comment('自提点id') INT(11)"` | |||
AddressType string `json:"address_type" xorm:"comment('') VARCHAR(255)"` | |||
MacaoAddress string `json:"macao_address" xorm:"comment('澳门世宝的珠海地址') TEXT"` | |||
VirtualGoodsInfo string `json:"virtual_goods_info" xorm:"not null default '' comment('') VARCHAR(1024)"` | |||
PayWay string `json:"pay_way" xorm:" default '' comment('') VARCHAR(255)"` | |||
ErrMsg string `json:"err_msg" xorm:" default '' comment('') VARCHAR(255)"` | |||
ParamData string `json:"param_data" xorm:" default '' comment('') VARCHAR(255)"` | |||
Platform string `json:"platform" xorm:" default '' comment('') VARCHAR(255)"` | |||
PayDiscountMoney string `json:"pay_discount_money" xorm:"default '0.00' comment('供应链同一商家总运费') DECIMAL(12,2)"` | |||
IsDeductDiscount int `json:"is_deduct_discount" xorm:"comment('') INT(11)"` | |||
} |
@@ -0,0 +1,32 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type MallOrdAfterSale struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"not null comment('用户id') index INT(11)"` | |||
CreateTime time.Time `json:"create_time" xorm:"created not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateTime time.Time `json:"update_time" xorm:"updated not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
OrdId int64 `json:"ord_id" xorm:"comment('订单id') BIGINT(20)"` | |||
OrdItemId int `json:"ord_item_id" xorm:"comment('订单item id') INT(11)"` | |||
RefundNum int `json:"refund_num" xorm:"comment('件数') INT(11)"` | |||
ApplyRefundMoney string `json:"apply_refund_money" xorm:"comment('申请退款金额') DECIMAL(12,2)"` | |||
ActualRefundAmount string `json:"actual_refund_amount" xorm:"comment('实际退款金额') DECIMAL(12,2)"` | |||
State int `json:"state" xorm:"comment('退款状态:0待处理 1已同意 2退货中 3换货已寄出 4已完成 5已拒绝') TINYINT(1)"` | |||
Type int `json:"type" xorm:"not null default 1 comment('售后类型:1退款 2退货退款 3换货') TINYINT(1)"` | |||
GoodsState int `json:"goods_state" xorm:"not null comment('货物状态:1未收到货 2已收到货') TINYINT(1)"` | |||
RefundMoneyReason int64 `json:"refund_money_reason" xorm:"not null default 1 comment('退货原因:1我不喜欢 2快递/物流一直未送到 3货物破损已拒收 4质量问题 5快递/物流无法跟踪记录 6空包裹') BIGINT(20)"` | |||
RefundMoneyReasonName string `json:"refund_money_reason_name" xorm:"comment('实际退款金额') DECIMAL(12,2)"` | |||
RefundGoodsMethod int `json:"refund_goods_method" xorm:"not null default 1 comment('退货方式:1自行寄件') TINYINT(1)"` | |||
Comment string `json:"comment" xorm:"comment('说明') TEXT"` | |||
Image string `json:"image" xorm:"comment('图片') TEXT"` | |||
Status int `json:"status" xorm:"not null comment('售后状态:1等待卖家审核 2卖家同意 3卖家已拒绝 4等待买家退货 5售后已完成 6售后已关闭(拒绝后48小时关闭)7撤销申请 8买家已发货') INT(11)"` | |||
IsRefund int `json:"is_refund" xorm:"not null comment('') INT(11)"` | |||
LogisticCompany string `json:"logistic_company" xorm:"not null default '' comment('物流公司') VARCHAR(255)"` | |||
LogisticNum string `json:"logistic_num" xorm:"not null default '' comment('快递单号') VARCHAR(255)"` | |||
OrdInfo string `json:"ord_info" xorm:"null comment('订单信息') TEXT"` | |||
SupplierAfterSaleId string `json:"supplier_after_sale_id" xorm:"default '' comment('供应商的售后id') VARCHAR(255)"` | |||
ContainShippingFee int `json:"contain_shipping_fee" xorm:"default '2' comment('退款金额是否包含运费,1:退款金额包括运费,2:退款金额不包括运费') TINYINT(1)"` | |||
} |
@@ -8,3 +8,12 @@ type AliPayPayParams struct { | |||
Uid string `json:"uid"` | |||
Phone string `json:"phone"` | |||
} | |||
type AliPayPayParams1 struct { | |||
Subject string `json:"subject" binding:"required"` | |||
Amount string `json:"amount" binding:"required"` | |||
OrderType string `json:"order_type" binding:"required"` | |||
OrdId string `json:"ord_id"` | |||
AgentUid string `json:"agent_uid"` | |||
NotifyUrl string `json:"notify_url"` | |||
PageUrl string `json:"page_url"` | |||
} |
@@ -17,6 +17,7 @@ func Init() { | |||
// 增加消费任务队列 | |||
func initConsumes() { | |||
jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder | |||
jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder | |||
//jobs[consumeMd.ZhiosAppreciationDevFunName] = ZhiosAppreciation | |||
@@ -263,9 +263,19 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosGuideStoreOrder", | |||
}, | |||
{ | |||
ExchangeName: "zhios.supplier_after_order.exchange", | |||
Name: "zhios_supplier_after_order", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "refund", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosSupplierAfterOrder", | |||
}, | |||
} | |||
const ( | |||
ZhiosSupplierAfterOrderFunName = "ZhiosSupplierAfterOrder" | |||
CanalOrderConsumeFunName = "CanalOrderConsume" | |||
CanalGuideOrderConsumeFunName = "CanalGuideOrderConsume" | |||
ZhiOsUserVisitIpAddressConsumeFunName = "ZhiOsUserVisitIpAddressConsume" | |||
@@ -0,0 +1,214 @@ | |||
package consume | |||
import ( | |||
"applet/app/cfg" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
md2 "applet/app/md" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/pay" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/iGoogle-ink/gopay/alipay" | |||
"github.com/streadway/amqp" | |||
"xorm.io/xorm" | |||
) | |||
func ZhiosSupplierAfterOrder(queue md.MqQueue) { | |||
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>") | |||
ch, err := rabbit.Cfg.Pool.GetChannel() | |||
if err != nil { | |||
logx.Error(err) | |||
return | |||
} | |||
defer ch.Release() | |||
//1、将自己绑定到交换机上 | |||
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) | |||
//2、取出数据进行消费 | |||
ch.Qos(1) | |||
delivery := ch.Consume(queue.Name, false) | |||
var res amqp.Delivery | |||
var ok bool | |||
for { | |||
res, ok = <-delivery | |||
if ok == true { | |||
//fmt.Println(string(res.Body)) | |||
fmt.Println(">>>>>>>>>>>>>>>>CanalOrderConsume<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleZhiosSupplierAfterOrder(res.Body) | |||
//_ = res.Reject(false) | |||
if err == nil { | |||
_ = res.Ack(true) | |||
} | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosSupplierAfterOrder(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosAppreciation | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println("===with", err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
fmt.Println("===with", err.Error()) | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
var afterOrder model.MallOrdAfterSale | |||
get, err := eg.Where("ord_id=?", canalMsg.Oid).Get(&afterOrder) | |||
if get == false || err != nil { | |||
return nil | |||
} | |||
if afterOrder.IsRefund == 0 && afterOrder.State == 4 { | |||
var order model.MallOrd | |||
get, err = eg.Where("ord_id = ?", canalMsg.Oid).Get(&order) | |||
if get == false || err != nil { | |||
return nil | |||
} | |||
if utils.StrToFloat64(afterOrder.ActualRefundAmount) == 0 { | |||
afterOrder.ActualRefundAmount = afterOrder.ApplyRefundMoney | |||
} | |||
wechatP12ApiclientCert := db.SysCfgGetWithDb(eg, canalMsg.Mid, "wechat_p12_apiclient_cert") | |||
wechatPayRefundType := db.SysCfgGetWithDb(eg, canalMsg.Mid, "wechat_pay_refund_type") | |||
alipayPayRefundType := db.SysCfgGetWithDb(eg, canalMsg.Mid, "alipay_pay_refund_type") | |||
switch order.PayChannel { | |||
case 2: // 支付宝支付 | |||
if order.TransactionId != "" && alipayPayRefundType == "1" { | |||
var param = &md2.AliPayPayParams1{} | |||
config, _ := CommMasterConfig(eg, canalMsg.Mid, param) | |||
config["trade_no"] = order.TransactionId | |||
config["refund_amount"] = afterOrder.ActualRefundAmount | |||
config["refund_reason"] = "自营退货" | |||
config["out_request_no"] = utils.OrderUUID(order.Uid) | |||
refund, err := pay.AlipayTradeRefund(config) | |||
utils.FilePutContents("mall_refund", utils.SerializeStr(config)) | |||
utils.FilePutContents("mall_refund", utils.SerializeStr(refund)) | |||
if err != nil { | |||
utils.FilePutContents("mall_refund", err.Error()) | |||
order.ErrMsg = err.Error() | |||
eg.Where("ord_id=?", order.OrdId).Cols("err_msg").Update(&order) | |||
return nil | |||
} | |||
if refund.AlipayTradeRefundResponse.Code != "10000" { | |||
order.ErrMsg = utils.SerializeStr(refund) | |||
eg.Where("ord_id=?", order.OrdId).Cols("err_msg").Update(&order) | |||
return nil | |||
} | |||
if refund.AlipayTradeRefundResponse.FundChange != "Y" { | |||
order.ErrMsg = utils.SerializeStr(refund) | |||
eg.Where("ord_id=?", order.OrdId).Cols("err_msg").Update(&order) | |||
return nil | |||
} | |||
fmt.Println(refund) | |||
fmt.Println(err) | |||
order.MoneyInAccount = 1 | |||
afterOrder.IsRefund = 1 | |||
} | |||
case 3: // 微信支付 | |||
if wechatP12ApiclientCert == "" || order.TransactionId == "" || wechatPayRefundType != "1" || order.AppId == "" { | |||
} else { | |||
params := map[string]string{ | |||
"subject": "自营商城退款", | |||
"total_fee": wxMoneyMulHundred(afterOrder.ActualRefundAmount), | |||
"amount": wxMoneyMulHundred(afterOrder.ActualRefundAmount), | |||
"out_refund_no": utils.Int64ToStr(afterOrder.OrdId), | |||
"p12_str": cfg.WxappletFilepath.URL + "/" + wechatP12ApiclientCert, | |||
"transaction_id": order.TransactionId, | |||
"pay_wx_mch_id": db.SysCfgGetWithDb(eg, canalMsg.Mid, "pay_wx_mch_id"), | |||
"pay_wx_api_key": db.SysCfgGetWithDb(eg, canalMsg.Mid, "pay_wx_api_key"), | |||
"uid": utils.IntToStr(order.Uid), | |||
"notify_url": "http://api.zhiyingos.com/api/v1/mall/refund/callback/" + canalMsg.Mid, | |||
} | |||
//params["p12_str"] = "D:\\Downloads\\WXCertUtil\\cert\\1534243971_20230825_cert\\" + wechatP12ApiclientCert | |||
//params["notify_url"] = strings.ReplaceAll(params["notify_url"], "http:", "https:") | |||
params["pay_wx_appid"] = order.AppId | |||
r, r1, err := pay.WxAppRefund(params) | |||
utils.FilePutContents("mall_refund", utils.SerializeStr(params)) | |||
utils.FilePutContents("mall_refund", utils.SerializeStr(r)) | |||
utils.FilePutContents("mall_refund", utils.SerializeStr(r1)) | |||
if err != nil { | |||
utils.FilePutContents("mall_refund", err.Error()) | |||
order.ErrMsg = err.Error() | |||
eg.Where("ord_id=?", order.OrdId).Cols("err_msg").Update(&order) | |||
return nil | |||
} | |||
if r.ReturnCode != "SUCCESS" { | |||
order.ErrMsg = utils.SerializeStr(r) | |||
eg.Where("ord_id=?", order.OrdId).Cols("err_msg").Update(&order) | |||
return nil | |||
} | |||
order.MoneyInAccount = 1 | |||
afterOrder.IsRefund = 1 | |||
} | |||
default: | |||
} | |||
eg.Where("id=?", afterOrder.Id).Cols("is_refund").Update(&afterOrder) | |||
eg.Where("ord_id=?", order.OrdId).Cols("money_in_account").Update(&order) | |||
} | |||
return nil | |||
} | |||
func CommMasterConfig(eg *xorm.Engine, dbName string, p *md2.AliPayPayParams1) (map[string]string, error) { | |||
//获取支付配置 | |||
req := map[string]string{ | |||
"pay_ali_use_type": db.SysCfgGetWithDb(eg, dbName, "pay_ali_use_type"), | |||
"private_key": db.SysCfgGetWithDb(eg, dbName, "pay_ali_private_key"), | |||
"app_id": db.SysCfgGetWithDb(eg, dbName, "pay_ali_app_id"), | |||
"rsa": db.SysCfgGetWithDb(eg, dbName, "pay_ali_key_len_type"), | |||
"pkcs": db.SysCfgGetWithDb(eg, dbName, "pay_ali_key_format_type"), | |||
} | |||
if req["pay_ali_use_type"] == "1" { | |||
req["private_key"] = db.SysCfgGetWithDb(eg, dbName, "pay_ali_new_private_key") | |||
req["app_id"] = db.SysCfgGetWithDb(eg, dbName, "pay_ali_new_app_id") | |||
appCertSN, err := alipay.GetCertSN(cfg.WxappletFilepath.URL + "/" + db.SysCfgGetWithDb(eg, dbName, "pay_app_cert_sn")) | |||
if err != nil { | |||
fmt.Println(err) | |||
return nil, err | |||
} | |||
if appCertSN == "" { | |||
fmt.Println(err) | |||
return nil, err | |||
} | |||
req["pay_app_cert_sn"] = appCertSN | |||
aliPayPublicCertSN, err := alipay.GetCertSN(cfg.WxappletFilepath.URL + "/" + db.SysCfgGetWithDb(eg, dbName, "pay_alipayrsa_public_key")) | |||
if err != nil { | |||
fmt.Println(err) | |||
return nil, err | |||
} | |||
if aliPayPublicCertSN == "" { | |||
fmt.Println(err) | |||
return nil, err | |||
} | |||
req["pay_alipayrsa_public_key"] = aliPayPublicCertSN | |||
} | |||
if req["private_key"] == "" || req["app_id"] == "" { | |||
return req, e.NewErr(400, "请在后台正确配置支付宝") | |||
} | |||
req["ord_id"] = p.OrdId | |||
req["amount"] = p.Amount | |||
req["subject"] = p.Subject | |||
req["order_type"] = p.OrderType | |||
return req, nil | |||
} |