|
|
package task
|
|
|
|
|
|
import (
|
|
|
"github.com/go-pg/pg"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"net/http"
|
|
|
"time"
|
|
|
|
|
|
"github.com/gavv/httpexpect"
|
|
|
"github.com/go-pg/pg"
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
. "github.com/onsi/gomega"
|
|
|
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
|
|
|
)
|
|
|
|
|
|
var _ = Describe("验收任务", func() {
|
|
|
var taskId int64
|
|
|
BeforeEach(func() {
|
|
|
_, err := pG.DB.QueryOne(
|
|
|
pg.Scan(&taskId),
|
|
|
"INSERT INTO tasks (task_id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, rob_info, bid_info, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
|
|
|
"testTaskId", "testCompanyId", "testTaskName", "testTaskType", "testSponsor", "testTaskStatus", "testReferenceResource", "testCustomerValue", "testTaskNature", "testSuMoney", "testAcceptanceStandard", "testTaskDescription", "testTaskPictureUrls", "testIsRewardTake", "testRobInfo", "testBidInfo", "testParticipators", "testTaskPercentage", "testSolveReport", "testSolvePictureUrls", "testCreateTime", "testReleaseTime")
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
})
|
|
|
Describe("验收任务", func() {
|
|
|
Context("", func() {
|
|
|
It("", func() {
|
|
|
Context("操作人对待验收的任务进行验收", func() {
|
|
|
BeforeEach(func() {
|
|
|
dayAfter, _ := time.ParseDuration("72h")
|
|
|
_, err := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 4, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
_, err1 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
Expect(err1).NotTo(HaveOccurred())
|
|
|
_, err2 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
_, err3 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO rob_infos (id, task_id ,receiver) VALUES (?, ?, ?)",
|
|
|
1, 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745099,
|
|
|
})
|
|
|
Expect(err3).NotTo(HaveOccurred())
|
|
|
_, err4 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
3, 101, 2499036607974745077, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
Expect(err4).NotTo(HaveOccurred())
|
|
|
_, err5 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
4, 101, 2499036607974745066, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
Expect(err5).NotTo(HaveOccurred())
|
|
|
})
|
|
|
It("验收成功", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"operator": "int64",
|
|
|
"participators": "array",
|
|
|
"taskPercentage": "array",
|
|
|
"solveReport": "string",
|
|
|
"solvePictureUrls": "array",
|
|
|
"operator": 2499036607974745077,
|
|
|
"participators": []int64{
|
|
|
2499036607974745077,
|
|
|
2499036607974745066,
|
|
|
},
|
|
|
"taskPercentage": []*domain.TaskPercentageItem{
|
|
|
{
|
|
|
Contributor: &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745099,
|
|
|
},
|
|
|
Percentage: 50,
|
|
|
SuMoney: 500.00,
|
|
|
},
|
|
|
{
|
|
|
Contributor: &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745077,
|
|
|
},
|
|
|
Percentage: 25,
|
|
|
SuMoney: 250.00,
|
|
|
},
|
|
|
{
|
|
|
Contributor: &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745066,
|
|
|
},
|
|
|
Percentage: 25,
|
|
|
SuMoney: 250.00,
|
|
|
},
|
|
|
},
|
|
|
"solveReport": "解决报告",
|
|
|
"solvePictureUrls": []string{
|
|
|
"url-1",
|
|
|
"url-2",
|
|
|
},
|
|
|
}
|
|
|
httpExpect.POST("/tasks/{taskId}/acceptance").
|
|
|
httpExpect.POST("/tasks/1/acceptance").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
...
|
...
|
@@ -38,12 +97,23 @@ var _ = Describe("验收任务", func() { |
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").Value("data").Object()
|
|
|
ContainsKey("data").Value("data").Object().
|
|
|
ContainsKey("taskStatus").ValueEqual("taskStatus", 5)
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
AfterEach(func() {
|
|
|
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
_, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true")
|
|
|
Expect(err1).NotTo(HaveOccurred())
|
|
|
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
|
|
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
_, err3 := pG.DB.Exec("DELETE FROM employees WHERE true")
|
|
|
Expect(err3).NotTo(HaveOccurred())
|
|
|
_, err4 := pG.DB.Exec("DELETE FROM rob_infos WHERE true")
|
|
|
Expect(err4).NotTo(HaveOccurred())
|
|
|
_, err5 := pG.DB.Exec("DELETE FROM su_money_transaction_records WHERE true")
|
|
|
Expect(err5).NotTo(HaveOccurred())
|
|
|
})
|
|
|
}) |
...
|
...
|
|