wx cash
This commit is contained in:
@@ -218,7 +218,13 @@ func AcceptJob(ctx *jxcontext.Context, jobID int) (err error) {
|
||||
JobID: jobID,
|
||||
JobOrderID: jxutils.GenJobOrderNo(),
|
||||
UserID: job.UserID,
|
||||
Status: model.JobOrderStatusAccept,
|
||||
// Status: model.JobOrderStatusAccept,
|
||||
}
|
||||
//美团会员任务
|
||||
if jobID == 1 {
|
||||
jobOrder.Status = model.JobOrderStatusSpec
|
||||
} else {
|
||||
jobOrder.Status = model.JobOrderStatusAccept
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
|
||||
@@ -60,6 +60,25 @@ func Pay(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (er
|
||||
return err
|
||||
}
|
||||
|
||||
func Cash(ctx *jxcontext.Context, orderID int) (err error) {
|
||||
func Cash(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
order = &model.Order{
|
||||
OrderID: int64(orderID),
|
||||
}
|
||||
payHandler = &financial.PayHandler{
|
||||
PayType: payType,
|
||||
Ctx: ctx,
|
||||
VendorPayType: vendorPayType,
|
||||
}
|
||||
)
|
||||
err = dao.GetEntity(db, order, "OrderID")
|
||||
payHandler.Order = order
|
||||
//如果用户没有对应账单信息就给他生成一条
|
||||
userBill, err := dao.GetUserBill(db, order.UserID, "")
|
||||
if userBill == nil {
|
||||
err = financial.AddUserBill(db, jxutils.GenBillID(), order.UserID)
|
||||
}
|
||||
err = payHandler.CreateRefund()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -70,6 +70,36 @@ func (p *PayHandler) CreateRefund() (err error) {
|
||||
switch p.PayType {
|
||||
case model.PayTypeTL:
|
||||
case model.PayTypeWX:
|
||||
//企业付款(提现)
|
||||
if p.VendorPayType == model.VendorPayTypeCompanyPay {
|
||||
param := &wxpayapi.TransfersParam{
|
||||
PartnerTradeNo: utils.Int64ToStr(p.Order.OrderID),
|
||||
CheckName: wxpayapi.CheckName,
|
||||
Amount: p.Order.PayPrice,
|
||||
Desc: "冲天猴儿app提现到账",
|
||||
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
||||
}
|
||||
if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeWxApp {
|
||||
param.OpenID = authInfo.GetAuthID()
|
||||
}
|
||||
result, err := api.WxpayAPI.Transfers(param)
|
||||
if err == nil {
|
||||
p.Order.PayFinishedAt = utils.Str2Time(result.PaymentTime)
|
||||
p.Order.Comment = result.DeviceInfo
|
||||
p.Order.OriginalData = utils.Format4Output(result, true)
|
||||
if result.ReturnMsg == "" {
|
||||
p.Order.Status = model.OrderStatusFinished
|
||||
} else {
|
||||
p.Order.Status = model.OrderStatusCanceled
|
||||
}
|
||||
dao.UpdateEntity(dao.GetDB(), p.Order)
|
||||
if result.ReturnMsg == "" {
|
||||
err = OnPayFinished(p.Order)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -97,7 +127,7 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
t1, _ := time.ParseInLocation("20060102150405", call.PayTime, loc)
|
||||
order.PayFinishedAt = utils.Time2Pointer(t1)
|
||||
order.PayFinishedAt = t1
|
||||
// order.TransactionID = call.ChnlTrxID
|
||||
order.OriginalData = utils.Format4Output(call, true)
|
||||
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
|
||||
@@ -197,7 +227,7 @@ func onWxpayFinished(msg *wxpayapi.PayResultMsg) (err error) {
|
||||
}
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
||||
order.PayFinishedAt = utils.Time2Pointer(wxpayapi.PayTime2Time(msg.TimeEnd))
|
||||
order.PayFinishedAt = wxpayapi.PayTime2Time(msg.TimeEnd)
|
||||
order.TransactionID = msg.TransactionID
|
||||
order.OriginalData = utils.Format4Output(msg, true)
|
||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
||||
|
||||
Reference in New Issue
Block a user