1
This commit is contained in:
@@ -11,6 +11,27 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// ApplyContract 电子合同申请回调
|
||||
func ApplyContract(callback *lakala.ApplyContractCallBack) error {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if callback.Code == "000000" {
|
||||
merchantInfo, err := dao.GetStoreContract(db, 0, callback.RespData.OrderNo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
merchantInfo.ContractStatus = callback.RespData.AuditStatus
|
||||
_, err = dao.UpdateEntity(db, merchantInfo, "ContractStatus")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateSeparateShop 商户分账业务回调(创建/修改)
|
||||
func CreateSeparateShop(callback *lakala.SeparateCallback) error {
|
||||
var (
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -17,14 +16,55 @@ import (
|
||||
|
||||
//#region 进件相关API
|
||||
|
||||
// LaKaLaApplyContract 拉卡拉申请签约合同
|
||||
func LaKaLaApplyContract(ctx *jxcontext.Context, apply *lakala.ApplyContractParam, storeID int) (*lakala.ApplyContractResp, error) {
|
||||
apply.OrderNo = lakala.GetOrderNumber(10)
|
||||
apply.RetUrl = lakala.ApplyContractCallback
|
||||
contractObj, err := api.LaKaLaApi.ApplyElectronicContract(apply)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
incomingObj := &model.LakalaContract{
|
||||
StoreId: storeID,
|
||||
ContractId: contractObj.OrderNo,
|
||||
ContractApplyId: utils.Int64ToStr(contractObj.EcApplyId),
|
||||
ContractStatus: "WAIT_AUDIT ",
|
||||
ApplyType: apply.EcTypeCode,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(incomingObj, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, incomingObj); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return contractObj, nil
|
||||
}
|
||||
|
||||
// QueryElectronicContract 拉卡拉签约合同查询
|
||||
func QueryElectronicContract(orderNo string, orgId int, ecApplyId string, storeID int) (*lakala.ElectronicContractStatus, error) {
|
||||
db := dao.GetDB()
|
||||
merchantInfo, err := dao.GetStoreContract(db, storeID, orderNo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
contractObj, err := api.LaKaLaApi.QueryElectronicContract(orderNo, orgId, ecApplyId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
merchantInfo.ContractStatus = contractObj.AuditStatus
|
||||
dao.UpdateEntity(db, merchantInfo, "ContractStatus")
|
||||
|
||||
return contractObj, nil
|
||||
}
|
||||
|
||||
// LaKaLaInComing 商户进件
|
||||
func LaKaLaInComing(ctx *jxcontext.Context, incoming *lakala.MerchantIncomingReq, storeId int) (string, error) {
|
||||
globals.SugarLogger.Debugf("---------lakala : %s ", utils.Format4Output(incoming, false))
|
||||
merchantNo, status, err := api.LaKaLaApi.MerchantIncoming(incoming)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
globals.SugarLogger.Debugf("---------LaKaLaInComing : %s , %s", merchantNo, status)
|
||||
incomingObj := &model.LakalaIncoming{
|
||||
StoreId: storeId,
|
||||
MerchantNo: merchantNo,
|
||||
@@ -833,4 +873,9 @@ func WithdrawalList(merchantNo, drawJnl, acctName, startTime, endTime string, pa
|
||||
return dao.WithdrawalList(merchantNo, drawJnl, acctName, start, end, pageSize, offset)
|
||||
}
|
||||
|
||||
// QueryApplyContractList 门店合同申请记录
|
||||
func QueryApplyContractList(orderNo string, storeID, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
return dao.QueryApplyContractList(orderNo, storeID, pageSize, offset)
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -5,6 +5,29 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetStoreContract(db *DaoDB, storeId int, orderId string) (*model.LakalaContract, error) {
|
||||
merchantObj := &model.LakalaContract{}
|
||||
param := []interface{}{}
|
||||
sql := ` SELECT * FROM lakala_contract WHERE 1=1`
|
||||
|
||||
if storeId != 0 {
|
||||
{
|
||||
sql += ` AND store_id = ?`
|
||||
param = append(param, storeId)
|
||||
}
|
||||
}
|
||||
|
||||
if orderId != "" {
|
||||
sql += ` AND contract_id = ?`
|
||||
param = append(param, orderId)
|
||||
}
|
||||
if err := GetRow(db, merchantObj, sql, param...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return merchantObj, nil
|
||||
}
|
||||
|
||||
// GetStoreInfoByMerchantID 门店进件/分账商户
|
||||
func GetStoreInfoByMerchantID(db *DaoDB, merchantNo string, storeId int, applyId, OrderID string) (*model.LakalaIncoming, error) {
|
||||
merchantObj := &model.LakalaIncoming{}
|
||||
@@ -284,3 +307,44 @@ func WithdrawalList(merchantNo, drawJnl, acctName string, startTime, endTime tim
|
||||
return pagedInfo, nil
|
||||
|
||||
}
|
||||
|
||||
// QueryApplyContractList 门店合同生气记录
|
||||
func QueryApplyContractList(orderNo string, storeID, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
db := GetDB()
|
||||
txDB, _ := Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
Rollback(db, txDB)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
|
||||
var recipient []*model.LakalaContract
|
||||
var param = []interface{}{}
|
||||
sql := ` SELECT SQL_CALC_FOUND_ROWS r.* FROM lakala_contract r WHERE 1=1 `
|
||||
|
||||
if storeID != 0 {
|
||||
sql += ` AND r.store_id = ?`
|
||||
param = append(param, storeID)
|
||||
}
|
||||
if orderNo != "" {
|
||||
sql += ` AND r.contract_id = ? `
|
||||
param = append(param, orderNo)
|
||||
}
|
||||
|
||||
sql += `
|
||||
ORDER BY r.id desc
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
param = append(param, pageSize, offset)
|
||||
|
||||
if err = GetRowsTx(txDB, &recipient, sql, param...); err == nil {
|
||||
pagedInfo = &model.PagedInfo{
|
||||
TotalCount: GetLastTotalRowCount2(db, txDB),
|
||||
Data: recipient,
|
||||
}
|
||||
}
|
||||
|
||||
return pagedInfo, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,22 @@ const (
|
||||
CmdTypeFallBack = "FALLBACK" // 分账退回
|
||||
)
|
||||
|
||||
type LakalaContract struct {
|
||||
ModelIDCUL
|
||||
ContractId string `orm:"column(contract_id);size(20)" json:"contractId"` // 订单编号
|
||||
ContractApplyId string `orm:"column(contract_apply_id);size(20)" json:"contractApplyId"` // 电子合同编号
|
||||
ContractStatus string `orm:"column(contract_status);size(20)" json:"ContractStatus"` // 合同状态
|
||||
StoreId int `orm:"column(store_id);size(16)" json:"storeId"` // 京西门店ID
|
||||
ApplyType string `orm:"column(apply_type);size(16)" json:"applyType"` // 申请类型
|
||||
}
|
||||
|
||||
func (o *LakalaContract) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"StoreID"},
|
||||
[]string{"contract_id"},
|
||||
}
|
||||
}
|
||||
|
||||
// LakalaIncoming 进件账户状态,分账状态
|
||||
type LakalaIncoming struct {
|
||||
ModelIDCUL
|
||||
|
||||
Reference in New Issue
Block a user